How To Force Oracle To Use Full Table Scan

Usually we need to execute a statement  as fast as possible and with minimal resource cost. Our first thought as a solution is the use of indexes, but not always is the solution, there are times when we want to access by FTS, of course you can force the full by using hints.

Testcase

Create a table and an index

FTS_1

 

See the default execution plan

FTS_2

 

Now we force the full, we must say that in this case the object_id is number.

FTS_3

 

Add zero to object_id cancel the use of index. It should be noted also that this is a very common mistake when writing sql sentences, since it avoids the use of indexes when we want to use them.

 

HTH – Antonio NAVARRO

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s