Scalar in a range (but textual not numeric)

From: Richard Huxton <dev(at)archonet(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Scalar in a range (but textual not numeric)
Date: 2004-02-25 19:18:20
Message-ID: 200402251918.20289.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Can't use any of the geometry related types since we've got text here not
numbers. Nothing in the archives seems quite right (AFAICT).

Any smart ideas? I'm happy to trade time when updating the blocks table
against lookup speed.

--
Richard Huxton
Archonet Ltd

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2004-02-25 20:36:40 Re: Scalar in a range (but textual not numeric)
Previous Message Robert Treat 2004-02-25 15:46:16 Re: [HACKERS] [SQL] Materialized View Summary