Hi everyone,
We were experiencing terrible performance of our queries under VPDs. The queries were taking approximately 7 mins on average just to complete when run under a domain.
However when run under DBA.ADMIN domain, the same query took < 7 seconds to complete.
Unfortunately, there was no way to run Saved Queries under another domain w/o changing domain grants to allow the Saved Queries to run under DBA.ADMIN (which is a NO NO!)
After examining the queries and tuning them, we managed to improve the performance from 7 mins to 7 seconds even with the VPD profile applied!
Here are the high level approaches and guidelines we used (hopefully it also applies to your queries but we can't guarantee anything)
1) Explain plan of the query when run under VPD profile shows that everytime rows are returned, they are joined with the VPD tables. We should therefore try to ensure that returned rows under each sub-query are as small as possible.
2) Use indexes to try to influence the optimiser to result in index unique scans
3) Hash Joins are extremely expensive on large data sets, hence try to avoid them if possible.
I have attached the query profiles for the query that saw dramatic improvements.
Query wo Optimisation.pdf
- shows the original explain plan without the optimisation
Query w Optimisation.pdf
- shows the new explain plan with optimisation
Note that the number of steps have been reduced from 69 to 67. Important finding is that even though the no. of steps reduced is only 2, this reduction is at the top level loops (refer to previous un-optimsed plan) hence, the performance improves dramatically as it has iterations to execute!
Hope this helps!
Ian
We were experiencing terrible performance of our queries under VPDs. The queries were taking approximately 7 mins on average just to complete when run under a domain.
However when run under DBA.ADMIN domain, the same query took < 7 seconds to complete.
Unfortunately, there was no way to run Saved Queries under another domain w/o changing domain grants to allow the Saved Queries to run under DBA.ADMIN (which is a NO NO!)
After examining the queries and tuning them, we managed to improve the performance from 7 mins to 7 seconds even with the VPD profile applied!
Here are the high level approaches and guidelines we used (hopefully it also applies to your queries but we can't guarantee anything)
1) Explain plan of the query when run under VPD profile shows that everytime rows are returned, they are joined with the VPD tables. We should therefore try to ensure that returned rows under each sub-query are as small as possible.
2) Use indexes to try to influence the optimiser to result in index unique scans
3) Hash Joins are extremely expensive on large data sets, hence try to avoid them if possible.
I have attached the query profiles for the query that saw dramatic improvements.
Query wo Optimisation.pdf
- shows the original explain plan without the optimisation
Query w Optimisation.pdf
- shows the new explain plan with optimisation
Note that the number of steps have been reduced from 69 to 67. Important finding is that even though the no. of steps reduced is only 2, this reduction is at the top level loops (refer to previous un-optimsed plan) hence, the performance improves dramatically as it has iterations to execute!
Hope this helps!
Ian
Comment