In general, table scans, except for very small tables, are the slowest way to retrieve data from a database.
Not necessarily. Table scans are the slowest way to retrieve a single value (or at most a small percentage of all values) from a large table. Table scans are the most efficient way to retrieve a medium to large percentage of the rows of a large table, which in Oracle terms is defined to be 5 blocks (or whatever you've set the appropriate init.ora parameters to). Why is this the case? Because for every index lookup the database needs to make a number of IO calls depending on the number of levels in the B-Tree index (or whatever structure you've decided to base the index on) and then make another IO call to retrieve the table block that the appropriate row is in. On average that will be 4 IO calls to retrieve a single row (hence the 5 block default on large table in Oracle). However, when retrieving many rows via a table scan there are many rows per table block (and Oracle uses a more efficient algorithm to retrieve multiple blocks at a time) resulting in fewer IOs per row (but more rows read obviously).
Management summary: table scans aren't necessarily a bad thing.
rdfield
In reply to Re: Re (3): DBI question with placeholders and IN
by rdfield
in thread DBI question with placeholders and IN
by dragonchild
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |