From: | Rob Kirkbride <rob(dot)kirkbride(at)thales-is(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Optimising Union Query. |
Date: | 2005-04-22 12:50:42 |
Message-ID: | 4268F322.1040106@thales-is.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I've got a query that takes quite some time to complete. I'm not an SQL
expert so I'm not sure how to improve things.
I've done a explain analyze and as I expected the database has to check
every row in each of the three tables below but I'm wondering if I can
do it much quicker by a use of an index or something. Each of the three
tables could have several thousand entries in. Basically the tables
contain data recorded against time then every hour a script deletes
entries that more than so many hours old.
select l.name,l.id from pa i,locations l where i.location=l.id union
select l.name,l.id from andu i,locations l where i.location=l.id union
select l.name,l.id from idu i,locations l where i.location=l.id;
Thanks for any help,
Rob
From | Date | Subject | |
---|---|---|---|
Next Message | Relyea, Mike | 2005-04-22 12:55:00 | Re: psqlodbc MSAccess and Postgresql |
Previous Message | Michael Fuhr | 2005-04-22 11:14:06 | Re: Record as a parameter to a function |