Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8F47D475AE4 for ; Thu, 21 Nov 2002 18:56:57 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D6BE3475F27 for ; Thu, 21 Nov 2002 18:56:55 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gALNussX018617; Thu, 21 Nov 2002 18:56:55 -0500 (EST) To: "Marc Mitchell" Cc: pgsql-admin@postgresql.org Subject: Re: Query performanc issue - too many table? In-reply-to: <00c101c291a1$9b99b820$7c01050a@marcmdelltop> References: <005501c2917f$61ca09a0$7c01050a@marcmdelltop> <13938.1037907911@sss.pgh.pa.us> <00c101c291a1$9b99b820$7c01050a@marcmdelltop> Comments: In-reply-to "Marc Mitchell" message dated "Thu, 21 Nov 2002 15:04:40 -0600" Date: Thu, 21 Nov 2002 18:56:54 -0500 Message-ID: <18616.1037923014@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/199 X-Sequence-Number: 6387 > The attached output is from 3 consecutive EXPLAIN ANALYSEs of the exact > same query. Each has a merge join floating somewhere within the query. > This has to be the culprit in terms of performance as this should be a > straightforward (albeit lengthy) step ladder keyed join query. It's not the merge join's fault; it's a question of a poorly chosen join order. I'm kinda surprised that GEQO didn't manage to find a better one, but your example shows that its odds of doing so aren't very good in this example. (I wonder whether GEQO shouldn't be augmented with some heuristics, so that it pays some attention to which relations have WHERE-clause links to which other ones, or restriction clauses that would make them useful to visit first. Right now I think it's a pretty blind search...) > So, is GEQC broken or just misconfigured on our box? If the latter, what > is the proper config? We've made no changes from the default settings? If > the former, can I simply shut it off? Is the only time this comes into > play equate to the number of times I see the debug message appear in the > postmaster log? I wouldn't shut it off. I would suggest raising the geqo_threshold a little bit, if you do a lot of 11-table joins, and you don't find the planning time unreasonable at 11 tables. Another possibility is to use explicit JOIN syntax to constrain the join order into a good one; that would save you planning time as well. See the manual. regards, tom lane