pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rigmor Ukuhe <rigmor.ukuhe@finestmedia.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Weird query speed
Date: Thu, 15 Jan 2004 11:40:46 -0500
Message-ID: <22803.1074184846@sss.pgh.pa.us> (raw)
In-Reply-To: <OEEHLFAIJHHMABJPIANIGELICHAA.rigmor.ukuhe@finestmedia.com>
References: <OEEHLFAIJHHMABJPIANIGELICHAA.rigmor.ukuhe@finestmedia.com>

"Rigmor Ukuhe" <rigmor.ukuhe@finestmedia.com> writes:
> query: select "NP_ID" from a WHERE "NP_ID" > '0'  [is slow]
>
> query: select "NP_ID" from a WHERE "NP_ID" > '1'  [is fast]
>
> There are about 37K rows and only about 100 of then are not "NP_ID" = 0

Yeah, it's scanning over all the zero values when you say "> 0" :-(

This is fixed for 7.5:

2003-12-20 20:23  tgl

	* src/: backend/access/nbtree/nbtinsert.c,
	backend/access/nbtree/nbtpage.c, backend/access/nbtree/nbtsearch.c,
	include/access/nbtree.h: Improve btree's
	initial-positioning-strategy code so that we never need to step
	more than one entry after descending the search tree to arrive at
	the correct place to start the scan.  This can improve the behavior
	substantially when there are many entries equal to the chosen
	boundary value.  Per suggestion from Dmitry Tkach, 14-Jul-03.

			regards, tom lane



view thread (2+ messages)

Message-ID: <22803.1074184846@sss.pgh.pa.us>
Permalink:  ../22803.1074184846@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22803.1074184846@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, rigmor.ukuhe@finestmedia.com
  Subject: Re: Weird query speed
  In-Reply-To: <22803.1074184846@sss.pgh.pa.us>

* 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