X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DFCD353DFF for ; Thu, 14 Apr 2005 03:47:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31722-10 for ; Thu, 14 Apr 2005 06:47:10 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2DA2453DFC for ; Thu, 14 Apr 2005 03:47:10 -0300 (ADT) 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 j3E6l7JC027510; Thu, 14 Apr 2005 02:47:07 -0400 (EDT) To: Richard Huxton Cc: Joel Fradkin , PostgreSQL Perform Subject: Re: speed of querry? In-reply-to: <425D573B.3080208@archonet.com> References: <001b01c54036$d49a2290$797ba8c0@jfradkin> <425D573B.3080208@archonet.com> Comments: In-reply-to Richard Huxton message dated "Wed, 13 Apr 2005 18:30:35 +0100" Date: Thu, 14 Apr 2005 02:47:06 -0400 Message-ID: <27509.1113461226@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/269 X-Sequence-Number: 11666 Richard Huxton writes: > In the first, we match outer.clientnum to inner.clientnum, in the second > it's "?column10?" - are you sure the query was identical in each case. > I'm guessing the unidentified column in query 2 is the reason for the > sort a couple of lines below it, which seems to take up a large chunk of > time. The "?column10?" is because EXPLAIN isn't excessively bright about reporting references to outputs of lower plan nodes. (Gotta fix that sometime.) The real point here is that the planner thought that a scan plus sort would be faster than scanning an index that exactly matched the sort order the Merge Join needed ... and it was wrong :-( So this is just the usual sort of question of "are your stats up to date, maybe you need to increase stats targets, or else play with random_page_cost, etc" ... regards, tom lane