Re: BUG #9833: daterange is not utilizing index correctly

From: Greg Stark <stark(at)mit(dot)edu>
To: bricklen <bricklen(at)gmail(dot)com>
Cc: shaharhd(at)gmail(dot)com, PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #9833: daterange is not utilizing index correctly
Date: 2014-04-04 11:36:38
Message-ID: CAM-w4HMjQgkQhuoZL_q5bJBU_oYd33=CYdXqe4qghuLZaanBUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 3 Apr 2014 21:39, "bricklen" <bricklen(at)gmail(dot)com> wrote:
>

> 1). [1978-07-15,1983-03-01) means "include 1978-07-15 and everything up
to - but not including - 1983-03-01", whereas BETWEEN is inclusive.

That means we can't simply rewrite the with as a BETWEEN clause. However
conceptually btree could be extended to handle @> operators like this.

This is a perfectly reasonable feature request but it's just not something
btree can handle currently. Btree operator classes can handle a few
specific operators <, <=, =, >=, and > and that's it I believe. Adding more
is non trivial work and range data types are fairly new.

> 2). I haven't tested, but wouldn't you need to create a GiST index for <@
to use the index?
> 3). Related to #2, have you tried installing the btree_gist extension to
allow the query planner to use the index?

Gist is more flexible about adding new operators. I don't know if that
means it has this one though. If it does you would have to build a new
index using the btree_gist operator class which is may not be worth it's
weight in your database.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2014-04-04 12:05:40 Re: BUG #9841: Need some help in sql query
Previous Message harukat 2014-04-04 10:22:16 BUG #9849: walreceiver's DEBUG message reports wrong timestamp