Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5FD8264FE7B for ; Fri, 12 Dec 2008 13:34:39 -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 14947-07 for ; Fri, 12 Dec 2008 13:34:31 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail129174.authsmtp.net (outmail129174.authsmtp.net [62.13.129.174]) by mail.postgresql.org (Postfix) with ESMTP id F0ECE64FCBD for ; Fri, 12 Dec 2008 13:34:30 -0400 (AST) Received: from mail-c188.authsmtp.com (mail-c188.authsmtp.com [62.13.128.25]) by punt8.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id mBCHXl5s086191; Fri, 12 Dec 2008 17:33:47 GMT Received: from [192.168.0.3] (85-211-226-82.dyn.gotadsl.co.uk [85.211.226.82]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id mBCHXjbb069125; Fri, 12 Dec 2008 17:33:45 GMT Subject: Re: benchmarking the query planner From: Simon Riggs To: Gregory Stark Cc: Robert Haas , Tom Lane , Kevin Grittner , "jd@commandprompt.com" , Josh Berkus , Greg Smith , pgsql-hackers@postgresql.org In-Reply-To: <87hc59s4qx.fsf@oxford.xeocode.com> 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> Content-Type: text/plain Date: Fri, 12 Dec 2008 17:33:29 +0000 Message-Id: <1229103209.8673.62.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 078923f0-c873-11dd-aecc-001871e930f4 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksafhtFaQdbaVxS HGQLW1xEUVp7WmB/ bwwfZQBDYEtPQQdo VlZBQE1QEQdtHhxP W2xtKnEoJVdGfndx Z0MsXXVYXAp6ck50 QE0CFXBVbWBjdWEe BBRFJlYHIx5Kfh5N bVEqXXANN2FJBC9q VzwTFhsSEA9kHWxf TwcGLVcbW0UKGDF0 WxAPVSwyEFcUDz03 JhogJ0R0 X-Authentic-SMTP: 61633235383639.cat.dmpriest.net.uk:1378/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! 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/965 X-Sequence-Number: 129594 On Fri, 2008-12-12 at 17:05 +0000, Gregory Stark wrote: > Simon Riggs writes: > > > The amount of I/O could stay the same, just sample all rows on block. > > Lifting the sample size will help large tables. Will it be perfect? No. > > But I'll take "better" over "not working at all". > > That will just raise the table size at which the problems start. It'll still > be a constant-sized sample. Work with me here. I want to make the situation better. It still won't be perfect, but is that an argument against any action at all? > 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. > > Incidentally we *do* do block sampling. We pick random blocks and then pick > random records within those blocks. This was new in, uh, 7.4? 8.0? Sometime > around then. It dramatically reduced the i/o requirements but there were long > discussions of how to do it without introducing biases. No, we pick random rows. On bigger tables, they get further apart typically and so we miss any clustering. I mean that we should pick a random block and read all rows on it. > > If we are going to quote literature we should believe all the > > literature. We can't just listen to some people that did a few tests > > with sample size, but then ignore the guy that designed the MS optimizer > > and many others. > > I'm not sure what you're talking about regarding "some people that did a few > tests". I looked around for the paper I keep referencing and can't find it on > my laptop. I'll look for it online. But it included a section which was a > survey of past results from other papers and the best results required > stupidly large sample sizes to get anything worthwhile. Even if you find it, we still need to know why we would listen to the research in the absent paper yet ignore the conclusion in the paper by the man in charge of the MS optimizer who said that block level sampling is a good idea. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support