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 4F9A29DC89B for ; Wed, 11 Jan 2006 19:03:06 -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 10039-07 for ; Wed, 11 Jan 2006 19:03:08 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id B02979DC898 for ; Wed, 11 Jan 2006 19:03:03 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k0BN35AE029000; Wed, 11 Jan 2006 18:03:05 -0500 (EST) To: =?iso-8859-1?Q?Jean-Philippe_C=F4t=E9?= cc: pgsql-performance@postgresql.org Subject: Re: Extremely irregular query performance In-reply-to: <20060111222900.EA357384020@crt0.crt.umontreal.ca> References: <20060111222900.EA357384020@crt0.crt.umontreal.ca> Comments: In-reply-to =?iso-8859-1?Q?Jean-Philippe_C=F4t=E9?= message dated "Wed, 11 Jan 2006 17:37:24 -0500" Date: Wed, 11 Jan 2006 18:03:05 -0500 Message-ID: <28999.1137020585@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.084 required=5 tests=[AWL=0.084] X-Spam-Score: 0.084 X-Spam-Level: X-Archive-Number: 200601/132 X-Sequence-Number: 16610 =?iso-8859-1?Q?Jean-Philippe_C=F4t=E9?= writes: > I'm running version 8.1 on a dedicated Sun v20 server (2 AMD x64's) > with 4Gb of RAM. I have recently noticed that the performance of > some more complex queries is extremely variable and irregular. > For example, I currently have a query that returns a small number > of rows (5) by joining a dozen of tables. A dozen tables? You're exceeding the geqo_threshold and getting a plan that has some randomness in it. You could either increase geqo_threshold if you can stand the extra planning time, or try increasing geqo_effort to get it to search a little harder and hopefully find a passable plan more often. See http://www.postgresql.org/docs/8.1/static/geqo.html http://www.postgresql.org/docs/8.1/static/runtime-config-query.html#RUNTIME-CONFIG-QUERY-GEQO I'm kinda surprised that you don't get better results with the default settings. We could tinker some more with the defaults, if you can provide evidence about better values ... regards, tom lane