Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: many Union all vs. inserting results to temp table

Re: many Union all vs. inserting results to temp table

From: <xhoster_at_gmail.com>
Date: 22 Mar 2006 22:05:34 GMT
Message-ID: <20060322171328.292$ha@newsreader.com>


deann15_at_yahoo.com wrote:
> I have a dynamic query which basically loop through an ID field in a
> table then build queries dynamically then union all the queries
> together, such as:
>
> select * from (complex subquery) where a = 1
> union all
> select * from (complex subquery) where a = 2
> union all
> select * from (complex subquery) where a = 3
> ...
>
> Depending on what a user select, the query could have a few thousand
> unions. My question is about scalability and performance: will it be
> better if inserting the results of every query to a global temp table
> then select * from the temptable instead of executing the long query
> all at once?

If you are going to use a temp table, why not populate it with the different values of a, then do one query joining "(complex subquery)" to the temp table?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB
Received on Wed Mar 22 2006 - 16:05:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US