Re: [HACKERS] Slow count(*) again...

From: David Wilson <david(dot)t(dot)wilson(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: david(at)lang(dot)hm, Vitalii Tymchyshyn <tivv00(at)gmail(dot)com>, Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>, Mladen Gogala <mladen(dot)gogala(at)vmsinfo(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Bruce Momjian <bruce(at)momjian(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: [HACKERS] Slow count(*) again...
Date: 2011-02-04 05:06:18
Message-ID: AANLkTi=A-70EgJ8yWDCn4hbyCaA0nFJFA3+zedan=nLS@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

On Thu, Feb 3, 2011 at 6:05 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

>
> If you want to randomly pick 10,000 rows out of all the rows that are
> going to be inserted in the table without knowing in advance how many
> there will be, how do you do that?
>

Reservoir sampling, as the most well-known option:
http://en.wikipedia.org/wiki/Reservoir_sampling

--
- David T. Wilson
david(dot)t(dot)wilson(at)gmail(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-02-04 05:11:07 Re: Compilation failed
Previous Message Itagaki Takahiro 2011-02-04 04:46:12 Re: pg_dump directory archive format / parallel pg_dump

Browse pgsql-performance by date

  From Date Subject
Next Message Samuel Gendler 2011-02-04 06:36:20 Re: [HACKERS] Slow count(*) again...
Previous Message Scott Marlowe 2011-02-04 04:57:31 Re: getting the most of out multi-core systems for repeated complex SELECT statements