X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 408E39DC88F for ; Mon, 9 Jan 2006 11:08:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83693-03 for ; Mon, 9 Jan 2006 11:08:47 -0400 (AST) X-Greylist: delayed 00:06:40.206759 by SQLgrey- Received: from roast.hq.mobyt.it (194-185-112-82.f5.ngi.it [194.185.112.82]) by postgresql.org (Postfix) with SMTP id 085F69DC89C for ; Mon, 9 Jan 2006 11:08:39 -0400 (AST) Received: (qmail 12763 invoked from network); 9 Jan 2006 15:58:56 +0100 Received: from webdev.hq.mobyt.it (HELO ?10.20.20.4?) (10.20.20.4) by 0 with SMTP; 9 Jan 2006 15:58:56 +0100 Message-ID: <43C27AFA.7060604@beccati.com> Date: Mon, 09 Jan 2006 16:02:18 +0100 From: Matteo Beccati User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Alessandro Baretta CC: pgsql-performance@postgresql.org Subject: Re: 500x speed-down: Wrong query plan? References: <43C26A5F.7040702@barettadeit.com> In-Reply-To: <43C26A5F.7040702@barettadeit.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200601/57 X-Sequence-Number: 16535 Hi Alessandro, > Nested Loop (cost=0.00..1017.15 rows=1 width=1146) (actual > time=258.648..258.648 rows=0 loops=1) > -> Seq Scan on ubicazione (cost=0.00..1011.45 rows=1 width=536) > (actual time=0.065..51.617 rows=12036 loops=1) > Filter: ((id_ente = 'dmd'::text) AND (allarme IS NULL) AND > (manutenzione IS NULL)) The problem seems here. The planner expects one matching row (and that's why it chooses a nested loop), but 12036 rows are matching this condition. Are you sure that you recentrly ANALYZED the table "ubicazione"? If so, try to increase statistics for the id_ente column. P.S. There is also an italian mailing list, if you are interested :) Best regards -- Matteo Beccati http://phpadsnew.com http://phppgads.com