Search Postgresql Archives

Optimising Union Query.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux