Re: Make COUNT(*) Faster?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Wampler <swampler(at)noao(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Make COUNT(*) Faster?
Date: 2005-07-08 16:12:23
Message-ID: 23283.1120839143@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Steve Wampler <swampler(at)noao(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-07-08 16:15:04 Re: Index creation question for expression (col1 || '-' || col2)
Previous Message Ying Lu 2005-07-08 16:08:41 Index creation question for expression (col1 || '-' || col2)