pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Torge <torgato@posteo.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Feature request for count_estimate(samplesize) aggregate or SAMPLE keyword
Date: Thu,  1 Sep 2022 01:49:40 +0000
Message-ID: <f0bcde70-0257-7b08-4e51-57e114314925@posteo.de> (raw)
In-Reply-To: <243115.1661996852@sss.pgh.pa.us>
References: <0e8b1eb9-97bf-0ddf-a487-ac4e4f6e0186@posteo.de>
	<243115.1661996852@sss.pgh.pa.us>

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 <torgato@posteo.de> 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 <condition>;
>
> 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






view thread (3+ messages)

Message-ID: <f0bcde70-0257-7b08-4e51-57e114314925@posteo.de>
Permalink:  ../f0bcde70-0257-7b08-4e51-57e114314925@posteo.de/
Also on:    postgresql.org/message-id/f0bcde70-0257-7b08-4e51-57e114314925@posteo.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: torgato@posteo.de, tgl@sss.pgh.pa.us
  Subject: Re: Feature request for count_estimate(samplesize) aggregate or SAMPLE keyword
  In-Reply-To: <f0bcde70-0257-7b08-4e51-57e114314925@posteo.de>
  References: <0e8b1eb9-97bf-0ddf-a487-ac4e4f6e0186@posteo.de> <243115.1661996852@sss.pgh.pa.us> <f0bcde70-0257-7b08-4e51-57e114314925@posteo.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox