Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oTZL2-0003EQ-Op for pgsql-general@arkaria.postgresql.org; Thu, 01 Sep 2022 01:49:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oTZL1-0004gb-NG for pgsql-general@arkaria.postgresql.org; Thu, 01 Sep 2022 01:49:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oTZL1-0004gS-Aa for pgsql-general@lists.postgresql.org; Thu, 01 Sep 2022 01:49:47 +0000 Received: from mout01.posteo.de ([185.67.36.65]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oTZKy-0002wU-RA for pgsql-general@lists.postgresql.org; Thu, 01 Sep 2022 01:49:46 +0000 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id DB556240026 for ; Thu, 1 Sep 2022 03:49:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1661996981; bh=rEi5QYzVGjGZZskJGCZD540EInWXWoxeLhd4Mgv5iLY=; h=Date:Subject:To:Cc:From:From; b=f4Miu43FdElJrl+VEp8sLQYxFzpO95F6mnj/TW6X0fRmU+YciampUSWhe7fyF7TfU yt0tWEdYs5Vq3uZhN1e7aScvlIEt3TT9dzyWUbKfQrfTUymPIsEA3Rjf08cl7MW3HU xGT/HIE0mZSc3KgvR6iTJE5mPwilHvxINc68ABiw8QkMbIbSOV7g85fL563Lh/bzY0 P8WmTeAwLelYf/Sl4hmINibCZ5w11qB3KvrggB2ojErZFChOHoxVsC43KzrA1Uhmbe 6dOioFdcuiHEVeJGTEJIT6nJHbJKCm/S3R85ropqZuBGs4KlSf/c14TMuGB68nTDaO bgVPcFMtXSxAA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MJ3rP1gw9z6tqD; Thu, 1 Sep 2022 03:49:40 +0200 (CEST) Message-ID: Date: Thu, 1 Sep 2022 01:49:40 +0000 MIME-Version: 1.0 Subject: Re: Feature request for count_estimate(samplesize) aggregate or SAMPLE keyword Content-Language: en-US To: Tom Lane Cc: pgsql-general@lists.postgresql.org References: <0e8b1eb9-97bf-0ddf-a487-ac4e4f6e0186@posteo.de> <243115.1661996852@sss.pgh.pa.us> From: Torge In-Reply-To: <243115.1661996852@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I am not aware of this, sounds like what I want. Will look into it. Thanks! Am 01.09.22 um 03:47 schrieb Tom Lane: > Torge writes: >> Now I would like to humbly propose a feature that gives an easy way to >> get a quick count estimate for any condition - index based or not - >> based on a random sample of rows, that does not require a custom >> function creation or complex SQL statement > Can't you do that already using TABLESAMPLE? For example, to > use a 1% sample: > > select count(*) * 100 from mytab tablesample system(1) where ; > > You do have to remember to multiply by the factor corresponding > to your sample rate, but aside from that annoyance this (a) > already exists, (b) is SQL-standard, and (c) can be adapted to > a lot of other kinds of analysis besides plain count(*). > > regards, tom lane