Re: [HACKERS] Much Ado About COUNT(*)

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: [HACKERS] Much Ado About COUNT(*)
Date: 2005-01-13 15:50:22
Message-ID: 877jmhxr9d.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Csaba Nagy <nagy(at)ecircle-ag(dot)com> writes:

> [snip]
> > The database could be clever and implement the same kind of sampling vacuum
> > does. That picks a random sampling of pages from the table without using an
> > index. But there's no way to implement the same kind of behaviour from the
> > user-visible features.
> ... meaning perhaps a new keyword accepted by SELECT, something like
> "SAMPLE 1000" ? Which would mean sample records in a 1:1000 ratio ?
> Would simplify (and probably speed up a lot) some estimating queries...

See:

http://www.jlcomp.demon.co.uk/faq/random.html

I think the Oracle syntax looks like

SELECT * FROM foo SAMPLE (0.1)

I don't think I would have picked this syntax but it seems like a better idea
to copy the existing practice rather than invent a new one.

There are some details, like what to do when there's a WHERE clause or joins.
Oracle disallows joins entirely and I'm unclear what the best thing to do
about where clauses would be.

--
greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2005-01-13 15:50:29 Re: vacuum vs open transactions
Previous Message Support (DBTools Software) 2005-01-13 15:49:54 [ANN] DBManager Professional 3.0.2 Released

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-01-13 15:56:12 Win32 config file extension, capitalization
Previous Message Tom Lane 2005-01-13 15:29:16 Re: Much Ado About COUNT(*)