Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C2D066500AC for ; Fri, 14 Nov 2008 13:07:54 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 32607-09 for ; Fri, 14 Nov 2008 13:07:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.avior.ca (mail.avior.ca [207.253.176.82]) by mail.postgresql.org (Postfix) with SMTP id 95680650378 for ; Fri, 14 Nov 2008 13:07:50 -0400 (AST) Message-ID: <491DB061.4020002@avior.ca> Date: Fri, 14 Nov 2008 12:07:45 -0500 From: Patrice Beliveau User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Difference in query plan Content-Type: multipart/mixed; boundary="------------000300040204040103020204" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/135 X-Sequence-Number: 31866 This is a multi-part message in MIME format. --------------000300040204040103020204 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Thanks, I'm already doing a vacuum full every night on all database, but the REINDEX fix it and now it's working fine But this raise a question 1) This table is cleared every night and recomputed, does this mean that I should REINDEX every night also 2) Why this thing didn't happen in the other schema Thanks again Patrice Beliveau wrote: > > I have a database in a production server (8.1.9) with to schema > > containing the sames table same index, same every thing, but with > > different data. When I execute a query in one schema, it take much more > > time to execute then the other schema. > [snip] > > I'm wondering where to start searching to fix this problem > > > Production server schema 1 query plan: > > Nested Loop (cost=569.23..634.43 rows=1 width=121) (actual > > time=1032.811..1032.811 rows=0 loops=1) > [snip] > > Total runtime: 1034.204 ms > > > Production server schema 2 query plan: > > Nested Loop (cost=133.42..793.12 rows=1 width=123) (actual > > time=0.130..0.130 rows=0 loops=1) > [snip] > > Total runtime: 0.305 ms > Well there's something strange - the estimated costs are fairly similar (643.43 vs 793.12) but the times are clearly very different (1034 vs 0.3ms) The suspicious line from the first plan is: > > -> Seq Scan on mrp m (cost=0.00..119.92 rows=5892 > > width=39) (actual time=0.343..939.462 rows=5892 loops=1) > This is taking up almost all the time in the query and yet only seems to be scanning 5892 rows. Run a vacuum verbose against table "mrp" and see if it's got a lot of dead rows. If it has, run VACUUM FULL and REINDEX against it and see if that solves your problem. I'm guessing you have / had a long-running transaction interfering with vacuum on this table, or perhaps a bulk update/delete? -- Richard Huxton Archonet Ltd -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance . --------------000300040204040103020204 Content-Type: text/x-vcard; charset=utf-8; name="pbeliveau.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pbeliveau.vcf" begin:vcard fn;quoted-printable:Patrice B=C3=A9liveau n;quoted-printable:B=C3=A9liveau;Patrice org;quoted-printable:AVIOR Produits Int=C3=A9gr=C3=A9s Inc. adr;quoted-printable:;;1001, autoroute 440 ouest;Laval;Qu=C3=A9bec;H7L 3W3;Canada email;internet:pbeliveau@avior.ca title:Directeur IT tel;work:(450) 629-6200 #410 tel;fax:(514) 324-6241 x-mozilla-html:FALSE url:www.avior.ca version:2.1 end:vcard --------------000300040204040103020204--