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 F08B73B56AB for ; Fri, 24 Dec 2004 01:47:45 +0000 (GMT) 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 42313-08 for ; Fri, 24 Dec 2004 01:47:35 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id C15DE3B56E2 for ; Fri, 24 Dec 2004 01:47:36 +0000 (GMT) Received: (qmail 21671 invoked from network); 24 Dec 2004 02:47:38 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 24 Dec 2004 02:47:38 +0100 To: pgsql-performance@postgresql.org Subject: Re: LIMIT causes SEQSCAN in subselect References: <200412102140.18456.josh@agliodbs.com> Message-ID: Date: Fri, 24 Dec 2004 02:47:40 +0100 From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <200412102140.18456.josh@agliodbs.com> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200412/285 X-Sequence-Number: 9660 > The fact that the estimator knows that the LIMIT is pointless because > there > are less rows in the subselect than the LIMIT will return is not > something we > want to count on; sometimes the estimator has innaccurate information. > The > UNIQUE index makes this more certain, except that I'm not sure that the > planner distinguishes between actual UNIQUE indexes and columns which are > estimated unique (per the pg_stats). And I think you can see in your > case > that there's quite a difference between a column we're CERTAIN is unique, > versus a column we THINK is unique. I think a UNIQUE constraint can permit several 'different' NULL values... better say "UNIQUE NOT NULL" ?