Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 81ED91337B2F for ; Thu, 9 Dec 2010 07:02:23 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 38546-03 for ; Thu, 9 Dec 2010 11:02:17 +0000 (UTC) X-Greylist: delayed 00:09:52.78916 by SQLgrey-1.7.6 Received: from mail.xgs-france.com (ns3.xgs-france.com [194.110.245.2]) by mail.postgresql.org (Postfix) with ESMTP id 78E8D133798E for ; Thu, 9 Dec 2010 07:02:15 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.xgs-france.com (Postfix) with ESMTP id 2B2FE848DC67; Thu, 9 Dec 2010 11:52:06 +0100 (CET) Received: from mail.xgs-france.com ([127.0.0.1]) by localhost (imap2.svcs.dc1.xgs-france.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MIApivnUf-sX; Thu, 9 Dec 2010 11:52:05 +0100 (CET) Received: from [10.1.5.133] (unknown [10.1.5.133]) by mail.xgs-france.com (Postfix) with ESMTP id B71F8848DC5A; Thu, 9 Dec 2010 11:52:05 +0100 (CET) Message-ID: <4D00B4DE.3030508@xgs-france.com> Date: Thu, 09 Dec 2010 11:52:14 +0100 From: Olivier Pala User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101027 Thunderbird/3.0.10 MIME-Version: 1.0 To: pgsql-performance@postgresql.org CC: Olivier Pala Subject: UNION and bad performance Content-Type: multipart/alternative; boundary="------------080602090406030301090907" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/155 X-Sequence-Number: 41607 This is a multi-part message in MIME format. --------------080602090406030301090907 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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* --------------080602090406030301090907 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --------------080602090406030301090907--