We have large amount of data partitioned on year value using range partition in oracle. We have used range partition but each partition contains data only for one year. When we write a query targeting a specific year, oracle fetches the information from that partition but still checks if the year is what we have specified. Since this year column is not part of the index it fetches the year from table and compares it. We have seen that any time the query goes to fetch table data it is getting too slow.
Can we somehow avoid oracle comparing the year values since we for sure know that the partition contains information for only one year.
Update:
The year data type on which partition is performed is of type number.
We are not selecting any additional columns. I am just performing a
count(*)
and no columns are being selected.If we remove the condition and target the query to specific partition as
select count(*) from table_name partition(part_2004)
it is faster whileselect count(*) from table where year = 2004
is way slower.The partition is on year column which is a number and is done something like below
year less than 2005 part_2004
year less than 2006 part_2005
year less than 2007 part_2006
...so on