jl66
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?
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?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Excellent!! Thanks all of you so much.
ASKER