Home » RDBMS Server » Performance Tuning » Performance tuning (cache sub query results) (Oracle 10g)
Performance tuning (cache sub query results) [message #483360] Sun, 21 November 2010 07:02 Go to next message
yosikal
Messages: 1
Registered: November 2010
Location: Israel
Junior Member
Hi Everyone,

I need some help with performance tuning for a query I'm running. The query is calculating average build time for projects when each project has several build connected to it. The builds subquery returning ~200000 rows is a constant query (no where clause containing reference to the projects table and therefore returns the same data always) and I think that Oracle is running the query for each row in projects table even though same results return. Is it possible to tell Oracle in some way to run this sub query once and cache the result?

Here is the query:

select
.....project.name,
.....(select avg(builds.end builds.start) from
..........(select project_name, start, end...) builds
.....where
..........build.project_name = projects.name) as project_avg
from
.....projects


Thanks in advance,
Yosi
Re: Performance tuning (cache sub query results) [message #483365 is a reply to message #483360] Sun, 21 November 2010 07:53 Go to previous message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You will find what Oracle does using explain plan.
See http://www.orafaq.com/forum/mv/msg/84315/433888/102589/#msg_433888

Quote:
Is it possible to tell Oracle in some way to run this sub query once and cache the result?

Use join instead of scalar subquery.
You can also use "factoring clause".
All these notions are explained in Database SQL Reference

Regards
Michel
Previous Topic: order by
Next Topic: Sql Taking More CPU time (merged)
Goto Forum:
  


Current Time: Sat Apr 27 12:09:15 CDT 2024