Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 7FFE1650443 for ; Fri, 12 Dec 2008 15:34:51 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 39549-06 for ; Fri, 12 Dec 2008 15:34:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp100.biz.mail.mud.yahoo.com (smtp100.biz.mail.mud.yahoo.com [68.142.201.176]) by mail.postgresql.org (Postfix) with SMTP id 5E0F8650411 for ; Fri, 12 Dec 2008 15:34:46 -0400 (AST) Received: (qmail 49064 invoked from network); 12 Dec 2008 19:34:44 -0000 Received: from unknown (HELO ?192.168.5.110?) (rm_pg@76.201.142.183 with plain) by smtp100.biz.mail.mud.yahoo.com with SMTP; 12 Dec 2008 19:34:43 -0000 X-YMail-OSG: BmI4euMVM1lXPqPqXrUukYKcnptla1V3mZjUsmAc6XJaS4M5FfgfiYtmKHnZu0KFj6kqNHlaSfFnasIfW9GNrmykZ4fFkwjQnIEVqOwND3EgShSM1YsT8s2Gwb1EFxrf1DVst3juha1Gk.qAjYl7G1z.GgHVnkXuLobYNt.CLVLvIRGdVD683dCziU.. X-Yahoo-Newman-Property: ymail-3 Message-ID: <4942BCD2.9070306@cheapcomplexdevices.com> Date: Fri, 12 Dec 2008 11:34:42 -0800 From: Ron Mayer User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: Gregory Stark CC: Simon Riggs , Robert Haas , Tom Lane , Kevin Grittner , "jd@commandprompt.com" , Josh Berkus , Greg Smith , pgsql-hackers@postgresql.org Subject: Re: benchmarking the query planner References: <603c8f070812061019r5aca3aajeaa5493b11c5feff@mail.gmail.com> <603c8f070812092025k6325e0fcud001b205a507a634@mail.gmail.com> <4313.1228931932@sss.pgh.pa.us> <603c8f070812101828p1bd7df49yb8c916adedb49fe1@mail.gmail.com> <9565.1229018968@sss.pgh.pa.us> <1229033073.13078.179.camel@hp_dx2400_1> <87ej0etkfh.fsf@oxford.xeocode.com> <1229039044.13078.193.camel@hp_dx2400_1> <4136ffa0812111823u645b6ec9wdca60b3da4b00499@mail.gmail.com> <1229072675.13078.196.camel@hp_dx2400_1> <603c8f070812120344m67ef2c1fs41806cfb4ff9e396@mail.gmail.com> <1229093975.13078.275.camel@ebony.2ndQuadrant> <87tz99s7bu.fsf@oxford.xeocode.com> <1229100057.8673.29.camel@ebony.2ndQuadrant> <87hc59s4qx.fsf@oxford.xeocode.com> In-Reply-To: <87hc59s4qx.fsf@oxford.xeocode.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200812/994 X-Sequence-Number: 129623 Gregory Stark wrote: > Simon Riggs writes: >> The amount of I/O could stay the same, just sample all rows on block. [....] > > It will also introduce strange biases. For instance in a clustered table it'll > think there are a lot more duplicates than there really are because it'll see > lots of similar values. But for ndistinct - it seems it could only help things. If the ndistinct guesser just picks max(the-current-one-row-per-block-guess, a-guess-based-on-all-the-rows-on-the-blocks) it seems we'd be no worse off for clustered tables; and much better off for randomly organized tables. In some ways I fear *not* sampling all rows on the block also introduces strange biases by largely overlooking the fact that the table's clustered. In my tables clustered on zip-code we don't notice info like "state='AZ' is present in well under 1% of blocks in the table", while if we did scan all rows on the blocks it might guess this. But I guess a histogram of blocks would be additional stat rather than an improved one.