Avatar of jl66
jl66
Flag for United States of America asked on

How to deal with repeatedly used query within a big query?

Have the query logic below:

select some columns
from ( Query1) a, from ( Query1) b, other_tables
where some conditions including col1 <> b.col1, etc AND
other conditions including ( select col2 from  ( Query1));

In the above query, Query1 comes from expensive operations (many joins, selects, etc)
My question is
Are there ways to highly efficiently use Query1? No need to query it every time.
It seems that a temp table can be created to hold the query results.  Dear gurus, what is the best way to handle it?

 
Oracle DatabaseSQL

Avatar of undefined
Last Comment
jl66

8/22/2022 - Mon
jl66

ASKER
the output from Query1 is not so big ( a few 1000s) but it involves in several big tables and many expensive operations, so I try to re-use the result but not try to re-query it many times.
SOLUTION
gplana

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
jl66

ASKER
Excellent!! Thanks all of you so much.
Your help has saved me hundreds of hours of internet surfing.
fblack61