Re: Make COUNT(*) Faster? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Make COUNT(*) Faster?
Date
Msg-id 23283.1120839143@sss.pgh.pa.us
Whole thread Raw
In response to Re: Make COUNT(*) Faster?  (Steve Wampler <swampler@noao.edu>)
List pgsql-sql
Steve Wampler <swampler@noao.edu> writes:
> Tom Lane wrote:
>> If you want something cheap, you could use the same technique the
>> planner uses nowadays: take RelationGetNumberOfBlocks() (which is
>> guaranteed accurate) and multiply by reltuples/relpages.

> Yes - this would be an excellent approximation for my needs!  The
> solution that Dawid Kuroczko suggested (just call "explain select *
> on ..." and parse the result) would be equivalent these days, right?

Close enough (the planner actually does some additional heuristic
stuff to avoid going crazy on corner cases).
        regards, tom lane


pgsql-sql by date:

Previous
From: Ying Lu
Date:
Subject: Index creation question for expression (col1 || '-' || col2)
Next
From: Tom Lane
Date:
Subject: Re: Index creation question for expression (col1 || '-' || col2)