How to remove duplicate subqueries - Mailing list pgsql-general

From Andrus
Subject How to remove duplicate subqueries
Date
Msg-id gaqe5n$1nul$1@news.hub.org
Whole thread Raw
List pgsql-general
I have query

SELECT ...
(
SELECT ... FROM (q1) p1 WHERE ...
UNION ALL
SELECT ... FROM (q1) p2 WHERE ...
) p3
GROUP BY f1,f2,f3

This query contains q1 query twice.
q1 takes long time to execute. PostgreSQL probably will execute it two
times.

How to force PostgreSQL 8.1 to execute q1 only once ?

Andrus.


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Triggers not working
Next
From: "Philip Hallstrom"
Date:
Subject: Help with query to return indexes (including functional ones!) on a given table