Re: [HACKERS] Much Ado About COUNT(*) - Mailing list pgsql-general

From Greg Stark
Subject Re: [HACKERS] Much Ado About COUNT(*)
Date
Msg-id 877jmhxr9d.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: [HACKERS] Much Ado About COUNT(*)  (Csaba Nagy <nagy@ecircle-ag.com>)
Responses Re: [HACKERS] Much Ado About COUNT(*)
Re: [HACKERS] Much Ado About COUNT(*)
List pgsql-general
Csaba Nagy <nagy@ecircle-ag.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

pgsql-general by date:

Previous
From: "Ed L."
Date:
Subject: Re: vacuum vs open transactions
Next
From: Alvaro Herrera
Date:
Subject: Re: vacuum vs open transactions