From: Tony Liao <tonyliao@yuehetone.com>
To: pgsql-admin@postgresql.org
Subject: "like" and index
Date: Wed, 25 Feb 2009 18:59:27 +0800
Message-ID: <8f750b7c0902250259w6065515as350aca3b5d7d8173@mail.gmail.com> (raw)
hi all,
I have a table table_A (id serial,prefix varchar),for example.
now I want to get the id of "johnsmith"'s prefix match
table_A.prefix,so I do select id from table_A where 'johnsmith' like
prefix||'%' ,the table_A is very large so I would like to make index.
create table_A_index on table_A(prefix)
I try to explain analyze,but it doesn't work ,it use seq scan.
I try another index. drop index table_A_index; create table_A_index on
table_A(prefix varchar_pattern_ops); it doesn't work,too.
thanks
ps:I have another table table_B would use table_B.prefix=
table_A.prefix.so how can I create the index?
yours, Tony
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tonyliao@yuehetone.com
Subject: Re: "like" and index
In-Reply-To: <8f750b7c0902250259w6065515as350aca3b5d7d8173@mail.gmail.com>
References: <8f750b7c0902250259w6065515as350aca3b5d7d8173@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox