确定需要多少块访问

时间:2016-10-24 02:30:22

标签: sql oracle block

oracle是否有办法弄清楚特定表的直接全扫描需要多少块访问?

2 个答案:

答案 0 :(得分:1)

执行全表扫描所需的I / O总数取决于表的大小(select blocks from user_segments where segment_name='TABLE_NAME'),多块读取计数(由DB_FILE_MULTIBLOCK_READ_COUNT参数控制)以及是否并行执行被用于操作。

答案 1 :(得分:0)

访问的块数基本上是查询所执行的逻辑/一致性的数量。您可以使用选项set autotrace traceonly statistics SQL * Plus来查看此统计信息值:

SQL> set autotrace traceonly statistics;
SQL> select * from customers;

115005 rows selected.


Statistics
----------------------------------------------------------
          4  recursive calls
          0  db block gets
       8215  consistent gets
        580  physical reads
          0  redo size
    4689008  bytes sent via SQL*Net to client
      84826  bytes received via SQL*Net from client
       7668  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
     115005  rows processed

consistent gets是查询使用的块数(也称为"逻辑I / O"。physical reads是从硬盘实际检索到的块数(因为它们是不在缓冲区缓存中。)