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

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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Scalar in a range (but textual not numeric)
Date: 2004-02-25 21:32:08
Message-ID: 6803.1077744728@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
Richard Huxton <dev(at)archonet(dot)com> writes:
> Large table representing non-overlapping blocks:
> blocks(id int4, min varchar, max varchar)

> SELECT * FROM blocks WHERE 'ABCDE' BETWEEN min AND max;

> The estimator gets the wrong plan because it doesn't realise there's
> (at most) only one block that can match.

Even if it did realize that, it couldn't do much, because this query
isn't indexable as it stands.

I wonder whether you could adapt the "line segment" datatype
(see contrib/seg/) into a sort of "text segment" thingy and use the
GiST indexing support on that.  You'd have a query like
	WHERE min_max_object overlaps-operator 'ABCDE'
and the overlaps operator would be a GiST-indexable one.

			regards, tom lane

In response to

Responses

pgsql-sql by date

Next:From: Richard HuxtonDate: 2004-02-25 22:08:55
Subject: Re: Scalar in a range (but textual not numeric)
Previous:From: Joe ConwayDate: 2004-02-25 20:56:43
Subject: Re: Scalar in a range (but textual not numeric)

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