btree_gin and ranges

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: btree_gin and ranges
Date: 2014-10-22 10:55:06
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Suggested patch adds GIN support contains operator for ranges over scalar column.

It allows more effective GIN scan. Currently, queries like
SELECT * FROM test_int4 WHERE i <= 1 and i >= 1
will be excuted by GIN with two scans: one is from mines infinity to 1 and
another is from -1 to plus infinity. That's because GIN is "generalized" and it
doesn't know a semantics of operation.

With patch it's possible to rewrite query with ranges
SELECT * FROM test_int4 WHERE i <@ '[-1, 1]'::int4range
and GIN index will support this query with single scan from -1 to 1.

Patch provides index support only for existing range types: int4, int8, numeric,
date and timestamp with and without time zone.

Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru

Attachment Content-Type Size
btree_gin_range-1.patch.gz application/x-gzip 7.6 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Александр Глухов 2014-10-22 11:31:15 ARMv5
Previous Message David Rowley 2014-10-22 10:37:03 Re: [PATCH] Simplify EXISTS subqueries containing LIMIT