Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance tuning - Query on partitioned vs non-partitioned table

I have two queries, one of which involves a partitioned table in the query while the other query is the same except that it involves the non-partitioned equivalent table. The original (non-partitioned table) query is performing better than the partitioned counter-part. I am not sure how to isolate the problem for this. Looking at the execution plan, I find that the indexes used are the same b/w the two queries and that the new query shows the PARTITION RANGE clause in its execution plan meaning that partition pruning is taking place. The query is of the following form:-

Select rownum, <some columns> 
from partTabA 
inner join tabB on condition1
inner join tabC on condition2
where partTabA.column1=<value> and <other conditions>
and partTabA.column2 in (select columns from tabD where conditions) 

where partTabA is the partitioned table and partTabA.column1 is the partitioning key(range partition). In the original query, this gets replaced by the non-partitioned equivalent of the same table. What parameters should I look at to find out why the new query performs badly. Tool that I have is Oracle SQL Developer.

like image 947
Ajay Avatar asked Dec 07 '25 01:12

Ajay


1 Answers

PARTITION RANGE ITERATOR does not necessarily mean that partition pruning is happening. You'll also want to look at the Pstart and Pstop in the explain plan, to see which partitions are being used.

There are several potential reasons the partitioned query will be slower, even though it's reading the same data. (Assuming that the partitioned query isn't properly pruning, and is reading from the whole table.)

  1. Reading from multiple local indexes may be much less efficient than reading from a single, larger index.
  2. There may be a lot of wasted space from large initial segment sizes, a large number of partitions, etc. Compare the segment sizes with this: select * from dba_segments where segment_name in ('PARTTABA', 'TABA'); If that's the issue, you may want to look into your tablespace settings, or using deferred segment creation.
like image 163
Jon Heller Avatar answered Dec 08 '25 16:12

Jon Heller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!