Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Inability to use function-based indexes at times
Hi Thomas,
My suspicion is that the optimizer is actually getting it right here.
Assuming an even distribution of numbers, then mod(x,10) < 2 is going to return approximately 20% of all data (note maths along with spelling, history, geography, physics, chemistry, biology and sex studies are all particularly weak areas in my education)
If this is correctish, then a conventional scan index would not be appropriate as it would be far too expensive. Note depending on your version of Oracle and how you have computed statistics, valid hints are ignored if the optimizer really really thinks you are wrong with your hint (if you listen carefully, you can even hear it mutter things such as "mad, been mad for bloody years...").
If you are determined to use the index, you can try using histograms (but if the data is evenly distributed then there would be zip benefit) or try deleting your stats, get the optimizer to adopt your hint, store the plan in a stored outline and use the store outline for future executions.
Good Luck
Richard
"Thomas Gaines" <Thomas.Gaines_at_noaa.gov> wrote in message
news:3D6AA635.9F5E6A21_at_noaa.gov...
Folks -
I've got a certain query that I'd like to speed up, but I'm at a loss
right now about how to do it.
I have a rather sizeable table (1.6 M rows) with a primary key
on the single column "id." My group will be displaying these points
on a map, and 1.6 M points is too many for the poor display. When
zoomed out completely, we want to display just 10% of the points,
and display more as we zoom in more. When mapping just a small
region, we can easily display every point in that region.
To get a representative sample of points, we use the mod() function
similar to this:
select count(*) from gravity.grav_31 where mod(id,10) < 1;
Elapsed: 00:00:00.09
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=354 Card=1 Bytes=5) 1 0 SORT (AGGREGATE) 2 1 INDEX (RANGE SCAN) OF 'GRAV_31_MODID'
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=532 Card=1 Bytes=5) 1 0 SORT (AGGREGATE) 2 1 INDEX (FAST FULL SCAN) OF 'SYS_C006718'