Hi,
I did this:
CREATE VIEW unionview AS
SELECT col, otherstuff FROM (heavy subquery)
WHERE col BETWEEN 1 AND 3
UNION ALL
SELECT col, otherstuff FROM (another heavy subquery)
WHERE col BETWEEN 4 AND 6;
hoping that the planner could use the WHERE conditions (like it would use check constraints on tables) to exclude one
ofthe subqueries, for a query like:
SELECT * FROM unionview WHERE col=2;
But it doesn't. (In PostgreSQL 8.4.5, at least.)
Is there a way (currently) to get the planner to use these conditions to exclude subqueries in the UNION ALL? Or is
thisa case of “sounds nice, but too rare to merit implementing”?
Thanks,
- Gulli