Re: Prefix LIKE search and indexes issue.

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Prefix LIKE search and indexes issue.
Date: 2010-07-25 09:28:33
Message-ID: puy6czykou.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <AANLkTims+x5BpfAXF+9_cOHiaGa7=B_NpN=hw99kGxsK(at)mail(dot)gmail(dot)com>,
Marcelo de Moraes Serpa <celoserpa(at)gmail(dot)com> writes:

> Some good souls hinted me at the prefix extension, but
> how would I use it?

Like this:

CREATE TABLE users (
id serial NOT NULL,
name text NOT NULL,
reversed_domain prefix_range NULL,
PRIMARY KEY (id)
);

CREATE INDEX users_dom_ix ON users USING gist (reversed_domain);

SELECT id, name, reversed_domain
FROM users
WHERE reversed_domain @> 'com.app.mycompany';

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Torsten Bronger 2010-07-25 10:15:06 Server load statistics
Previous Message Ireneusz Pluta 2010-07-25 05:59:03 Re: psql problem