Re: Feature request for count_estimate(samplesize) aggregate or SAMPLE keyword

From: Torge <torgato(at)posteo(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Feature request for count_estimate(samplesize) aggregate or SAMPLE keyword
Date: 2022-09-01 01:49:40
Message-ID: f0bcde70-0257-7b08-4e51-57e114314925@posteo.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)posteo(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sushant Postgres 2022-09-01 09:47:50 Vacuum Full is not returning space to OS
Previous Message Tom Lane 2022-09-01 01:47:32 Re: Feature request for count_estimate(samplesize) aggregate or SAMPLE keyword