Re: View vs. Statement Query Plan - Mailing list pgsql-general

From Gregory Seidman
Subject Re: View vs. Statement Query Plan
Date
Msg-id 20020605144946.GA19448@jamaica.cs.brown.edu
Whole thread Raw
In response to Re: View vs. Statement Query Plan  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: View vs. Statement Query Plan  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Martijn van Oosterhout sez:
[...]
} Nifty example:
}
} select lower(f) from (select f from a union select f from b);
} (select lower(f) from a) union (select lower(f) from b);
}
} If table a has "HELLO" and table b has "hello", the first will produce two
} rows of output, whereas the second produce only one. To work, you require
} the function to be *invertable* (1-to-1 mapping) which is pretty strict. Off
} the top of my head I'd say the vast majority would fail that test.
}
} UNION ALL would be fine I think, as long as the functions ware cachable and
} there were no aggregates. Basically, as long all you're pushing down is a
} cacheable projection.

As long as you aren't messing with the columns (no projections, no value
modifications, no aggregation), it is $\sigma_p(A) \cup \sigma_p(B)$ vs.
$\sigma_p(A \cup B)$. These are equivalent, regardless of whether it is a
proper UNION or a UNION ALL.

} Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
--Greg


pgsql-general by date:

Previous
From: "sheetal"
Date:
Subject: Help...
Next
From: Oleg Bartunov
Date:
Subject: Re: Insight into indexes? (or inverting then externally)