spgist text_ops and LIKE - Mailing list pgsql-hackers

From Robert Haas
Subject spgist text_ops and LIKE
Date
Msg-id CA+TgmobxzEkZO-bxWM+7qeuewG481eGqVEyfhDWHq7rokUKY8Q@mail.gmail.com
Whole thread Raw
Responses Re: spgist text_ops and LIKE
List pgsql-hackers
Is spgist intended to support prefix searches with LIKE?

I ask because, first, it seems like something spgist ought to be good
at (unless I'm confused), and, second, the text_ops opfamily includes
these operators:

~<~(text,text)~<=~(text,text)~>=~(text,text)~>~(text,text)

...which seems to be the same operators that are used for btree
pattern-matching searches:

rhaas=# explain select count(*) from person where last_name like 'WAR%';                                       QUERY
PLAN
------------------------------------------------------------------------------------------Aggregate
(cost=2519.27..2519.28rows=1 width=0)  ->  Bitmap Heap Scan on person  (cost=24.70..2496.75 rows=9005 width=0)
Filter:(last_name ~~ 'WAR%'::text)        ->  Bitmap Index Scan on person_tpo  (cost=0.00..22.45
 
rows=900 width=0)              Index Cond: ((last_name ~>=~ 'WAR'::text) AND
(last_name ~<~ 'WAS'::text))
(5 rows)

...but when I create an index like this:

create index person_spg on person using spgist (last_name text_ops);

...I can't get LIKE to use it, even if I disable seqscans.

Thoughts?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Refactoring log_newpage
Next
From: Jim Nasby
Date:
Subject: Re: feature request - datum_compute_size and datum write_should be public