Thread: Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

From
"Kevin Grittner"
Date:
Matthew Wakeling <matthew@flymine.org> wrote:

> This is an FAQ.

I just added it to the wiki FAQ page:

http://wiki.postgresql.org/wiki/FAQ#Why_is_.22SELECT_count.28.2A.29_FROM_bigtable.3B.22_slow.3F

-Kevin


Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

From
Ivan Voras
Date:
Kevin Grittner wrote:
> Matthew Wakeling <matthew@flymine.org> wrote:
>
>> This is an FAQ.
>
> I just added it to the wiki FAQ page:
>
> http://wiki.postgresql.org/wiki/FAQ#Why_is_.22SELECT_count.28.2A.29_FROM_bigtable.3B.22_slow.3F

Maybe you could add a short note why an estimation like from the
pg_class table is usually enough.

Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

From
"Kevin Grittner"
Date:
Ivan Voras <ivoras@freebsd.org> wrote:

> Maybe you could add a short note why an estimation like from the
> pg_class table is usually enough.

OK.  Will do.

-Kevin

Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

From
Greg Smith
Date:
Kevin Grittner wrote:
Matthew Wakeling <matthew@flymine.org> wrote: 
This is an FAQ.   
 
I just added it to the wiki FAQ page:
http://wiki.postgresql.org/wiki/FAQ#Why_is_.22SELECT_count.28.2A.29_FROM_bigtable.3B.22_slow.3F 
The content was already there, just not linked into the main FAQ yet:  http://wiki.postgresql.org/wiki/Slow_Counting

-- 
Greg Smith    2ndQuadrant   Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com  www.2ndQuadrant.com

Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

From
"Kevin Grittner"
Date:
Greg Smith <greg@2ndquadrant.com> wrote:

> The content was already there, just not linked into the main FAQ
> yet:
> http://wiki.postgresql.org/wiki/Slow_Counting

For a question asked this frequently, it should probably be in the
FAQ.  I'll add a link from there to the more thorough write-up.

-Kevin

Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

From
Greg Smith
Date:
Kevin Grittner wrote:
Greg Smith <greg@2ndquadrant.com> wrote: 
The content was already there, just not linked into the main FAQ
yet: 
http://wiki.postgresql.org/wiki/Slow_Counting   
 
For a question asked this frequently, it should probably be in the
FAQ.  I'll add a link from there to the more thorough write-up.

There's a whole list of FAQs that are documented on the wiki but not in the main FAQ yet leftover from before the main FAQ was hosted there.  You can see them all at http://wiki.postgresql.org/wiki/Frequently_Asked_Questions

I just haven't had time to merge those all usefully into the main FAQ.

-- 
Greg Smith    2ndQuadrant   Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com  www.2ndQuadrant.com

Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

From
"Kevin Grittner"
Date:
Greg Smith <greg@2ndquadrant.com> wrote:

> There's a whole list of FAQs that are documented on the wiki but
> not in the main FAQ yet leftover from before the main FAQ was
> hosted there. You can see them all at
> http://wiki.postgresql.org/wiki/Frequently_Asked_Questions
>
> I just haven't had time to merge those all usefully into the main
> FAQ.

Well, unless you object to the way I did it, there's one down.
Should I remove it from the list of "Other FAQs" on the page you
cite?

(Of course, it goes without saying that you're welcome to improve
upon anything I put in there.)

-Kevin

Re: Slow "Select count(*) ..." query on table with 60 Mio. rows

From
Greg Smith
Date:
Kevin Grittner wrote:
Greg Smith <greg@2ndquadrant.com> wrote: 
There's a whole list of FAQs that are documented on the wiki but
not in the main FAQ yet leftover from before the main FAQ was
hosted there. You can see them all at 
http://wiki.postgresql.org/wiki/Frequently_Asked_Questions

I just haven't had time to merge those all usefully into the main
FAQ.   
 
Well, unless you object to the way I did it, there's one down. 
Should I remove it from the list of "Other FAQs" on the page you
cite?

Sure; everyone should feel free to assimilate into the main FAQ and wipe out anything on that smaller list.  Those are mainly topics where the discussion of workarounds and approaches can be much longer than standard FAQ length, so I suspect many of the answers are going to be a very brief summary with a link to longer discussion.  If you come across a really small one, we might even wipe out the original page once it's merged in.

-- 
Greg Smith    2ndQuadrant   Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com  www.2ndQuadrant.com