Hi,
This is prompted by the previous thread on "SQL Technique Question". I
have the following query, extracted from a PHP script, where $dt is a
date provided to the script.
SELECT created, topic_id, 0, 0, 0, 0 FROM topic
WHERE created >= $dt AND page_type IN (1, 2)
UNION
SELEC
Each of your queries has the filter xxx >= $dt where the xxx is the first column in each select. You could simplify the query by turning the unioned selects into a sub-query and then putting the $dt filter in the outer query.
I don't know if this will cause performance problems though. If Postgre
Aaron Bono wrote:
Each of your queries has the filter xxx >= $dt where the xxx is the
first column in each select. You could simplify the query by turning
the unioned selects into a sub-query and then putting the $dt filter in
the outer query.
It would probably have to be two subqueries unle
> AFAIK PostgreSQL does not support materialized views but it's
> interesting that you mention that because in essence the query is used
> to materialize a view, i.e., it's part of an INSERT / SELECT into a
> table which is then joined back to the other tables to construct a web
> page as well
Richard Broersma Jr <[EMAIL PROTECTED]> writes:
> http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html
> However, I am not sure if this link shows how postgresql supports
> materialized views or if it just shows how to simulate a materialized
> view with procedural code.
The lat
I haven't stared at your query as long as you have so I may have missed something but it looks like in all the selects you are combining the first column in the select is the column you filter on. So the the outer query doesn't have to know wiether it is a new or changed row:
SELECT * FROM ( S
Aaron Bono wrote:
I haven't stared at your query as long as you have so I may have missed
something but it looks like in all the selects you are combining the
first column in the select is the column you filter on. So the the
outer query doesn't have to know wiether it is a new or changed row:
"Aaron Bono" <[EMAIL PROTECTED]> writes:
> I haven't stared at your query as long as you have so I may have missed
> something
Likewise I'm perhaps speaking too quickly, but at the risk of making a fool of
myself: you should perhaps realize that UNION has to do a fair amount of work
to eliminate