Re: count * performance issue

From: Mark Mielke <mark(at)mark(dot)mielke(dot)cc>
To: Robins Tharakan <tharakan(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: count * performance issue
Date: 2008-03-11 03:01:51
Message-ID: 47D5F61F.4080305@mark.mielke.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Robins Tharakan wrote:
> Hi,
>
> I have been reading this conversation for a few days now and I just
> wanted to ask this. From the release notes, one of the new additions
> in 8.3 is (Allow col IS NULL to use an index (Teodor)).
>
> Sorry, if I am missing something here, but shouldn't something like
> this allow us to get a (fast) accurate count ?
>
> SELECT COUNT(*) from table WHERE indexed_field IS NULL
> +
> SELECT COUNT(*) from table WHERE indexed_field IS NOT NULL

For PostgreSQL: You still don't know whether the row is visible until
you check the row. That it's NULL or NOT NULL does not influence this truth.

Cheers,
mark

--
Mark Mielke <mark(at)mielke(dot)cc>

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Joshua D. Drake 2008-03-11 03:08:44 Re: count * performance issue
Previous Message Robins Tharakan 2008-03-11 02:57:05 Re: count * performance issue