Re: UNION and bad performance

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

 



Hello,

 

UNION will remove all duplicates, so that the result additionally requires to be sorted.

Anyway,  for performance issues, you should always start investigation with explain analyze .

regards,

 

Marc Mamin

 

From: pgsql-performance-owner@xxxxxxxxxxxxxx [mailto:pgsql-performance-owner@xxxxxxxxxxxxxx] On Behalf Of Olivier Pala
Sent: Donnerstag, 9. Dezember 2010 11:52
To: pgsql-performance@xxxxxxxxxxxxxx
Cc: Olivier Pala
Subject: UNION and bad performance

 

Hi,

I have a performance trouble with UNION query


First I have this view :

    SELECT a,b,c FROM table1, table2 WHERE jointure AND condition

    Result : 150 000 records in 1~2 s



Then, I adding an UNION into the same view :

    SELECT a,b,c FROM table1, table2 WHERE jointure AND condition
    UNION
    SELECT a,b,c FROM table3

    Result : 150 200 records in 6~7 s



Why, do I have bad performance only for 200 adding records ?

Thanks

SGBD : Postgres 8.3 et 8.4


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux