azzazzello
Technical User
Hi,
Suppose I have the following query
SELECT sum(some_value) from some_table s
where s.date in (date1,date2,date3)
Suppose I want to make it contingent on some other table and basically do the following
SELECT sum(some_value) from some_table s
where s.date in ( select distinct(date) from other_table o where o.update_time >= ( select max(update_time) from some_table ))
Lets say that the subquery when ran by iself takes 0.3 of a second. Let's say there are 60K records in some_table. What I seem to be experiencing is that the select with subquery takes an INORDINATE amount of time. Is it because the nested subquery has to be reran for EVERY row? The result is static - I'd love for it to just be run once. Can this be done without 2 queries and temporary tables?
Thank you!
Suppose I have the following query
SELECT sum(some_value) from some_table s
where s.date in (date1,date2,date3)
Suppose I want to make it contingent on some other table and basically do the following
SELECT sum(some_value) from some_table s
where s.date in ( select distinct(date) from other_table o where o.update_time >= ( select max(update_time) from some_table ))
Lets say that the subquery when ran by iself takes 0.3 of a second. Let's say there are 60K records in some_table. What I seem to be experiencing is that the select with subquery takes an INORDINATE amount of time. Is it because the nested subquery has to be reran for EVERY row? The result is static - I'd love for it to just be run once. Can this be done without 2 queries and temporary tables?
Thank you!