total_count
                  
                  
                  from t1
                  
                  
                  where counter1 > (select count(*) from t2 where 42=42)
                  
                  
                  and counter2 > (select count(*) from t2 where 42=42)
                  
                  
                  
                  
                  
                  можно ли провернуть какую магию, чтобы этот подзапрос не выполнять лишние 2 раза?:
                  
                  
                  
                  
                  
                  select
                  
                  
                  id
                  
                  
                  ,date
                  
                  
                  ,etc
                  
                  
                  ,(select count(*) from t2 where 42=42) total_count
                  
                  
                  from t1
                  
                  
                  where counter1 > total_count
                  
                  
                  and counter2 > total_count
                  
                  
                
Можно https://postgrespro.ru/docs/postgrespro/10/queries-with
А это правда, что оптимизатор постгреса не догадается один раз выполнить этот подзапрос?
Обсуждают сегодня