Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XcZ2B-0002BB-R7 for pgsql-performance@arkaria.postgresql.org; Fri, 10 Oct 2014 12:10:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XcZ2A-0001fh-JS for pgsql-performance@arkaria.postgresql.org; Fri, 10 Oct 2014 12:10:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XcZ29-0001fX-Bn for pgsql-performance@postgresql.org; Fri, 10 Oct 2014 12:10:57 +0000 Received: from smtp-out1.gransy.com ([77.78.126.51]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XcZ21-0002Km-6P for pgsql-performance@postgresql.org; Fri, 10 Oct 2014 12:10:55 +0000 Received: from smtp-out.gransy.com (localhost [127.0.0.1]) by smtp-out1.gransy.com (Postfix) with ESMTP id 5CA2A36006E for ; Fri, 10 Oct 2014 14:10:16 +0200 (CEST) Received: from smtp.gransy.com (smtp.simplia.cz [77.78.126.20]) by smtp-out1.gransy.com (Postfix) with ESMTP id E4083360037; Fri, 10 Oct 2014 14:10:15 +0200 (CEST) Received: from 2.emaily.eu (elizabeth.gransy.com [89.187.132.199]) (Authenticated sender: tv@fuzzy.cz) by smtp.gransy.com (Postfix) with ESMTPA id 31FBF19A035E; Fri, 10 Oct 2014 14:10:12 +0200 (CEST) Received: from 212.47.19.46 (SquirrelMail authenticated user tv@fuzzy.cz) by 2.emaily.eu with HTTP; Fri, 10 Oct 2014 14:10:13 +0200 Message-ID: In-Reply-To: References: <541A2335.3060100@agliodbs.com> <5420B71C.6010208@agliodbs.com> <5429D517.3090900@agliodbs.com> <542C4E60.3030505@agliodbs.com> <542DADEB.2080103@agliodbs.com> Date: Fri, 10 Oct 2014 14:10:13 +0200 Subject: Re: Yet another abort-early plan disaster on 9.3 From: "Tomas Vondra" To: "Greg Stark" Cc: "Josh Berkus" , "Peter Geoghegan" , "Simon Riggs" , "Jeff Janes" , "Merlin Moncure" , "postgres performance list" User-Agent: SquirrelMail/1.4.22 MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Dne 10 Říjen 2014, 13:16, Greg Stark napsal(a): > On Thu, Oct 2, 2014 at 8:56 PM, Josh Berkus wrote: >> Yes, it's only intractable if you're wedded to the idea of a tiny, >> fixed-size sample. If we're allowed to sample, say, 1% of the table, we >> can get a MUCH more accurate n_distinct estimate using multiple >> algorithms, of which HLL is one. While n_distinct will still have some >> variance, it'll be over a much smaller range. > > I've gone looking for papers on this topic but from what I read this > isn't so. To get any noticeable improvement you need to read 10-50% of > the table and that's effectively the same as reading the entire table > -- and it still had pretty poor results. All the research I could find > went into how to analyze the whole table while using a reasonable > amount of scratch space and how to do it incrementally. I think it's really difficult to discuss the estimation without some basic agreement on what are the goals. Naturally, we can't get a perfect estimator with small samples (especially when the sample size is fixed and not scaling with the table). But maybe we can improve the estimates without scanning most of the table? FWIW I've been playing with the adaptive estimator described in [1] and the results looks really interesting, IMHO. So far I was testing it on synthetic datasets outside the database, but I plan to use it instead of our estimator, and do some more tests. Would be helpful to get a collection of test cases that currently perform poorly. I have collected a few from the archives, but if those who follow this thread can provide additional test cases / point to a thread describing related etc. that'd be great. It certainly won't be perfect, but if it considerably improves the estimates then I believe it's step forward. Ultimately, it's impossible to improve the estimates without increasing the sample size. [1] http://ftp.cse.buffalo.edu/users/azhang/disc/disc01/cd1/out/papers/pods/towardsestimatimosur.pdf regards Tomas -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance