Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 6D5CB6322F0 for ; Sun, 22 Mar 2009 23:19:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 37553-03 for ; Sun, 22 Mar 2009 23:18:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 8245363219F for ; Sun, 22 Mar 2009 23:19:01 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n2N2IvgA021520; Sun, 22 Mar 2009 22:18:57 -0400 (EDT) To: marcin mank cc: kouber@saparev.com, pgsql-performance@postgresql.org Subject: Re: LIMIT confuses the planner In-reply-to: References: <49A295F0.5010405@saparev.com> <49A2A450.20002@archonet.com> <49A2DFFA.8000001@saparev.com> <18725.1235412110@sss.pgh.pa.us> <49A429A3.9010803@saparev.com> <17814.1237757356@sss.pgh.pa.us> Comments: In-reply-to marcin mank message dated "Mon, 23 Mar 2009 01:12:14 +0100" Date: Sun, 22 Mar 2009 22:18:57 -0400 Message-ID: <21519.1237774737@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL=0.010 X-Spam-Level: X-Archive-Number: 200903/324 X-Sequence-Number: 33246 marcin mank writes: > I hit an interestinhg paper on n_distinct calculation: > http://www.pittsburgh.intel-research.net/people/gibbons/papers/distinct-values-chapter.pdf I don't think we're quite ready to make ANALYZE read every row of a table in order to estimate n_distinct. It is an interesting paper in that it says that you have to do that in order to get *provably* good estimates, but I've not abandoned the hope of getting *usually* good estimates without so much work. regards, tom lane