Skip site navigation (1) Skip section navigation (2)

Re: Scalar in a range (but textual not numeric)

From: Richard Huxton <dev(at)archonet(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Scalar in a range (but textual not numeric)
Date: 2004-02-26 08:03:11
Message-ID: 200402260803.11523.dev@archonet.com (view raw or flat)
Thread:
Lists: pgsql-sql
On Wednesday 25 February 2004 22:37, Tom Lane wrote:
> 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)

Aha! I was trying something like that, but couldn't get it quite right and it 
was getting too late for me to see clearly.

Thanks Tom, I'll have a play with this later today.
-- 
  Richard Huxton
  Archonet Ltd

In response to

pgsql-sql by date

Next:From: Richard HuxtonDate: 2004-02-26 08:15:16
Subject: Re: updating remote database
Previous:From: Sumita Biswas (sbiswas)Date: 2004-02-26 05:51:12
Subject: Unicode Support

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group