Re: Index usage for tstzrange? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Index usage for tstzrange?
Date
Msg-id 1326.1363838330@sss.pgh.pa.us
Whole thread Raw
In response to Index usage for tstzrange?  (Josh Berkus <josh@agliodbs.com>)
Responses Re: Index usage for tstzrange?
Re: Index usage for tstzrange?
List pgsql-performance
Josh Berkus <josh@agliodbs.com> writes:
> I just noticed that if I use a tstzrange for convenience, a standard
> btree index on a timestamp won't get used for it.  Example:

> table a (
>     id int,
>     val text,
>     ts timestamptz
> );
> index a_ts on a(ts);

> SELECT * FROM a WHERE ts <@ tstzrange('2013-01-01','2013-01-01 00:10:00')

> ... will NOT use the index a_ts.

Well, no.  <@ is not a btree-indexable operator.

What I find more disturbing is that this is what I get from the example
in HEAD:

regression=# explain SELECT * FROM a WHERE ts <@ tstzrange('2013-01-01','2013-01-01 00:10:00');
ERROR:  XX000: type 1184 is not a range type
LOCATION:  range_get_typcache, rangetypes.c:1451

Haven't traced through it to determine exactly what's happening, but
isn't this a legitimate usage?  And if it isn't, surely a more
user-facing error ought to be getting thrown somewhere upstream of here.

            regards, tom lane


pgsql-performance by date:

Previous
From: Mark Kirkwood
Date:
Subject: Re: New server setup
Next
From: Vasilis Ventirozos
Date:
Subject: Re: Index usage for tstzrange?