On 05/18/2014 07:44 PM, James Cloos wrote:
> Is there a better way to answer the question, "Do ANY rows match?"
> without having to return the list of matching rows? I didn't find
> anything googling.
select exists (select 1 from retest where active is true and ? ~ re);
> Is there a way to index such a table/query?
There are several ways to index such a query. If there are very many
rows but with only a few being active, then a partial index will do wonders.
http://www.postgresql.org/docs/current/static/indexes-partial.html
Otherwise, it is possible to use an index for regular expressions using
the pg_trgm extension.
http://www.postgresql.org/docs/current/static/pgtrgm.html
--
Vik