【问题标题】:Table not doing index scan表不做索引扫描
【发布时间】:2011-10-25 10:09:26
【问题描述】:

嘿伙计,我的表正在执行索引快速全扫描是出于某种原因。

这是我的查询

SELECT bo.bid,cu.cid 
FROM ass2master_booking bo, ass2master_customer cu 
WHERE bo.cid = cu.cid 
and rownum < 135000; 

这是跟踪文件

SELECT bo.bid,cu.cid 
FROM ass2master_booking bo, ass2master_customer cu 
WHERE bo.cid = cu.cid 
and rownum < 135000


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      2      0.00       0.00          0          0          0           0
Fetch     9001      0.19       0.41        387       2131          0      134999
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     9004      0.19       0.41        387       2131          0      134999

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 5594  

Rows     Row Source Operation
-------  ---------------------------------------------------
134999  COUNT STOPKEY (cr=2131 pr=387 pw=189 time=411804 us)
134999   HASH JOIN  (cr=2131 pr=387 pw=189 time=276737 us)
150000    INDEX FAST FULL SCAN CUSTOMER_CID_IDX (cr=320 pr=315 pw=0 time=263 us)(object   id 332052)
7412    TABLE ACCESS FULL ASS2MASTER_BOOKING (cr=1811 pr=44 pw=0 time=7566 us)

基本上,我被告知要为非结构化数据添加结构,我得到了 2 个包含 150,000 行的表,并确定以下哪种结构是最好的。

  • 非聚集索引
  • 聚集索引
  • 散列聚类
  • 非结构化数据。

上面给出了我选择进行测试的查询。

【问题讨论】:

    标签: performance oracle


    【解决方案1】:

    您选择了两个表的大部分,因此索引访问没有意义。 (至少甲骨文是这么认为的)

    它使用索引快速全扫描而不是表访问全扫描,因为它在索引中找到它需要的所有内容 (cu.cid) 而不需要表。

    我不明白你的意思

    非聚集索引聚集索引散列聚集非结构化数据。

    更新:

    我认为我使用的经验法则:

    如果您需要超过 20% 的表,我希望进行全表扫描。 如果您需要不到 5% 的表,我希望有某种索引访问。

    在调整 SQL 语句时,我做的第一件事就是查看执行计划并检查 oracle 期望从每个步骤返回的行数。如果这些数字完全错误,则执行计划可能非常糟糕。

    【讨论】:

    • 嗨 jens,什么时候应该使用索引?当您在特定表中选择特定值时?像 where customername = 'tom'?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2011-06-28
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    • 2021-03-19
    相关资源
    最近更新 更多