Oracle 10g Full table scan(parallel access) 100x times faster than index access by rowid

toddlermenot

There was a query in production which was running for several hours(5-6) hours. I looked into its execution plan, and found that it was ignoring a parallel hint on a huge table. Reason - it was using TABLE ACCESS BY INDEX ROWID. So after I added a /*+ full(huge_table) */ hint before the parallel(huge_table) hint, the query started running in parallel, and it finished in less than 3 minutes. What I could not fathom was the reason for this HUGE difference in performance. The following are the advantages of parallel FTS I can think of:

  1. Parallel operations are inherently fast if you have more idle CPUs.
  2. Parallel operations in 10g are direct I/O which bypass buffer cache which means there is no risk of "buffer busy waits" or any other contention for buffer cache.

Sure there are the above advantages but then again the following disadvantages are still there:

  1. Parallel operations still have to do I/O, and this I/O would be more than what we have for TABLE ACCESS BY INDEX ROWID as the entire table is scanned and is costlier(all physical reads)
  2. Parallel operations are not very scalable which means if there aren't enough free resources, it is going to be slow

With the above knowledge at hand, I see only one reason that could have caused the poor performance for the query when it used ACCESS BY INDEX ROWID - some sort of contention like "busy buffer waits". But it doesn't show up on the AWR top 5 wait events. The top two events were "db file sequential read" and "db file scattered read". Is there something else that I have missed to take into consideration? Please enlighten me.

Justin Cave

First, without knowing anything about your data volumes, statistics, the selectivity of your predicates, etc. I would guess that the major benefit you're seeing is from doing a table scan rather than trying to use an index. Indexes are not necessarily fast and table scans are not necessarily slow. If you are using a rowid from an index to access a row, Oracle is limited to doing single block reads (sequential reads in Oracle terms) and that it's going to have to read the same block many times if the block has many rows of interest. A full table scan, on the other hand, can do nice, efficient multiblock reads (scattered reads in Oracle terms). Sure, an individual single block read is going to be more efficient than a single multiblock read but the multiblock read is much more efficient per byte read. Additionally, if you're using an index, you've potentially got to read a number of blocks from the index periodically to find out the next rowid to read from the table.

You don't actually need to read all that much data from the table before a table scan is more efficient than an index. Depending on a host of other factors, the tipping point is probably in the 10-20% range (that's a very, very rough guess). Imagine that you had to get a bunch of names from the phone book and that the phone book had an index that included the information you're filtering on and the page that the entry is on. You could use an index to find the name of a single person you want to look at, flip to the indicated page, record the information, flip back to the index, find the next name, flip back, etc. Or you could simply start at the first name, scan until you find a name of interest, record the information, and continue the scan. It doesn't take too long before you're better off ignoring the index and just reading from the table.

Adding parallelism doesn't reduce the amount of work your query does (in fact, adding in parallel query coordination means that you're doing more work). It's just that you're doing that work over a shorter period of elapsed time by using more of the server's available resources. If you're running the query with 6 parallel slaves, that could certainly allow the query to run 5 times faster overall (parallel query obviously scales a bit less than linearly because of overheads). If that's the case, you'd expect that doing a table scan made the query 20 times faster and adding parallelism added another factor of 5 to get your 100x improvement.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Java: Getter and setter faster than direct access?

From Dev

Oracle Index - full table scan/lock

From Dev

Is 1D texture memory access faster than 1D global memory access?

From Dev

Is multiplication faster than array access?

From Dev

OpenCL sample program executes 10 times faster on CPU than on GPU

From Dev

How do I force access by index rowid in Oracle?

From Dev

Oracle 10g Full table scan(parallel access) 100x times faster than index access by rowid

From Dev

Why is this usage of concatentation in StringBuilder's constructor 100X faster than calling append()?

From Dev

Is it faster when access the contiguous physical address than virtual address?

From Dev

Confusion regarding Nested Table Extend in oracle 10g

From Dev

Oracle query results pagination without TABLE FULL SCAN data access method

From Dev

Are git tags faster to access than git commits?

From Dev

'Id' is not an index in this table - MS ACCESS

From Dev

oracle index on rowid column

From Dev

Difference between table access by index rowid BATCHED and table access by index rowid

From Dev

Table access vs function call + conditional determination: which is faster?

From Dev

Spark final task takes 100x times longer than first 199, how to improve

From Dev

Python Dictionary Access Faster than List Index Access

From Dev

Why is the second execution of this combinator 10 times faster than the first?

From Dev

Oracle Index - full table scan/lock

From Dev

Access table data by row index

From Dev

Is 1D texture memory access faster than 1D global memory access?

From Dev

Is multiplication faster than array access?

From Dev

How do I force access by index rowid in Oracle?

From Dev

MSSQL: Why is this index 10 times faster than the other one?

From Dev

Access raw partition from a virtual machine - is it faster than a virtual disk?

From Dev

Faster way to query Access table

From Dev

Oracle SQL EXPLAIN PLAN - full table access

From Dev

MS Access: Audit a table with a full log table to track table changes

Related Related

  1. 1

    Java: Getter and setter faster than direct access?

  2. 2

    Oracle Index - full table scan/lock

  3. 3

    Is 1D texture memory access faster than 1D global memory access?

  4. 4

    Is multiplication faster than array access?

  5. 5

    OpenCL sample program executes 10 times faster on CPU than on GPU

  6. 6

    How do I force access by index rowid in Oracle?

  7. 7

    Oracle 10g Full table scan(parallel access) 100x times faster than index access by rowid

  8. 8

    Why is this usage of concatentation in StringBuilder's constructor 100X faster than calling append()?

  9. 9

    Is it faster when access the contiguous physical address than virtual address?

  10. 10

    Confusion regarding Nested Table Extend in oracle 10g

  11. 11

    Oracle query results pagination without TABLE FULL SCAN data access method

  12. 12

    Are git tags faster to access than git commits?

  13. 13

    'Id' is not an index in this table - MS ACCESS

  14. 14

    oracle index on rowid column

  15. 15

    Difference between table access by index rowid BATCHED and table access by index rowid

  16. 16

    Table access vs function call + conditional determination: which is faster?

  17. 17

    Spark final task takes 100x times longer than first 199, how to improve

  18. 18

    Python Dictionary Access Faster than List Index Access

  19. 19

    Why is the second execution of this combinator 10 times faster than the first?

  20. 20

    Oracle Index - full table scan/lock

  21. 21

    Access table data by row index

  22. 22

    Is 1D texture memory access faster than 1D global memory access?

  23. 23

    Is multiplication faster than array access?

  24. 24

    How do I force access by index rowid in Oracle?

  25. 25

    MSSQL: Why is this index 10 times faster than the other one?

  26. 26

    Access raw partition from a virtual machine - is it faster than a virtual disk?

  27. 27

    Faster way to query Access table

  28. 28

    Oracle SQL EXPLAIN PLAN - full table access

  29. 29

    MS Access: Audit a table with a full log table to track table changes

HotTag

Archive