pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Scalar in a range (but textual not numeric)
Date: Wed, 25 Feb 2004 17:37:30 -0500
Message-ID: <7219.1077748650@sss.pgh.pa.us> (raw)
In-Reply-To: <7179.1077748348@sss.pgh.pa.us>
References: <200402251918.20289.dev@archonet.com>
	<6803.1077744728@sss.pgh.pa.us>
	<200402252208.55502.dev@archonet.com>
	<7179.1077748348@sss.pgh.pa.us>

I wrote:
> try writing
> 	WHERE 'ABCDE' >= pr_min AND 'ABCDE' <= pr_max
> 	      AND pr_min < (SELECT pr_min FROM table
> 			    WHERE pr_min > 'ABCDE'
> 			    ORDER BY pr_min LIMIT 1)
> The idea here is to add an upper bound on pr_min to the index scan
> conditions, so that the scan can stop short of the end of the index.

Argh, got that backwards.  What you are missing is a *lower* bound on
pr_min, and the index scan will therefore run from the start of the
index up to pr_min = 'ABCDE'.  So reverse the sense of the added test:

	      AND pr_min >= (SELECT pr_min FROM table
			     WHERE pr_min <= 'ABCDE'
			     ORDER BY pr_min DESC LIMIT 1)

			regards, tom lane



view thread (11+ messages)  latest in thread

Message-ID: <7219.1077748650@sss.pgh.pa.us>
Permalink:  ../7219.1077748650@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7219.1077748650@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-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dev@archonet.com
  Subject: Re: Scalar in a range (but textual not numeric)
  In-Reply-To: <7219.1077748650@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