pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joshua D. Drake <jd@commandprompt.com>
To: Robins Tharakan <tharakan@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: count * performance issue
Date: Mon, 10 Mar 2008 20:08:44 -0700
Message-ID: <20080310200844.2281f0e8@jd-laptop> (raw)
In-Reply-To: <36af4bed0803101957u6078127fq78dc3384fe78de5d@mail.gmail.com>
References: <f966c2ee0803052142l6a105678jfe2da92a0d9371@mail.gmail.com>
	<47D00DB2.7040007@emolecules.com>
	<18451.1204824562@sss.pgh.pa.us>
	<200803071727.36146.josh@agliodbs.com>
	<13345.1204940295@sss.pgh.pa.us>
	<87r6eia9tz.fsf@oxford.xeocode.com>
	<12ba3bf00803101354w15b023e1o237f564a1b01105f@mail.gmail.com>
	<Pine.GSO.4.64.0803101853090.25041@westnet.com>
	<36af4bed0803101957u6078127fq78dc3384fe78de5d@mail.gmail.com>

On Tue, 11 Mar 2008 08:27:05 +0530
"Robins Tharakan" <tharakan@gmail.com> wrote:

> SELECT COUNT(*) from table WHERE indexed_field IS NULL
> +
> SELECT COUNT(*) from table WHERE indexed_field IS NOT NULL

If the selectivity is appropriate yes. However if you have 1 million
rows, and 200k of those rows are null (or not null), it is still going
to seqscan.

joshua d. drake

-- 
The PostgreSQL Company since 1997: http://www.commandprompt.com/ 
PostgreSQL Community Conference: http://www.postgresqlconference.org/
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL SPI Liaison | SPI Director |  PostgreSQL political pundit

Attachments:

  signature.asc (application/pgp-signature, 188B) download

view thread (62+ messages)  latest in thread

Message-ID: <20080310200844.2281f0e8@jd-laptop>
Permalink:  ../20080310200844.2281f0e8@jd-laptop/
Also on:    postgresql.org/message-id/20080310200844.2281f0e8@jd-laptop

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jd@commandprompt.com, tharakan@gmail.com
  Subject: Re: count * performance issue
  In-Reply-To: <20080310200844.2281f0e8@jd-laptop>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox