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 16:32:08 -0500
Message-ID: <6803.1077744728@sss.pgh.pa.us> (raw)
In-Reply-To: <200402251918.20289.dev@archonet.com>
References: <200402251918.20289.dev@archonet.com>

Richard Huxton <dev@archonet.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



view thread (11+ messages)  latest in thread

Message-ID: <6803.1077744728@sss.pgh.pa.us>
Permalink:  ../6803.1077744728@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6803.1077744728@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: <6803.1077744728@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