Bjørn T Johansen wrote: > Thx for your suggestions. Tried to use NOT EXISTS and the query was about half a second quicker so not > much difference... > But when I try to run the 3 queries separately, then they are very quick, 2 barely measurable and the > third takes about 1,5 seconds. The union query > takes a little over 9 seconds, so I guess the union part is the bottleneck? Looking at EXPLAIN (ANALYZE) output should tell you. If yes, is UNION ALL an option for you? That should be cheaper. Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general