Re: best practices with index on varchar column

From: Dawid Kuroczko <qnex42(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: best practices with index on varchar column
Date: 2005-03-22 09:49:25
Message-ID: 758d5e7f050322014953c311fe@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, 22 Mar 2005 18:22:24 +0900, Layet Benjamin
<benjamin(at)moonfactory(dot)co(dot)jp> wrote:
> Can I use an index on a varchar column to optimize the SELECT queries that
> use " column LIKE 'header%' "?
> If yes what is the best tree algotithm to use ?

Yes, that is the correct place. The best tree algorithm is B-Tree,
which is the default. So no need for giving 'USING ...' to CREATE INDEX.

The other types of indexes are either not trees (HASH), different
and more complex (GiST, RTREE) kinds of trees which are there
for different kinds of data (spatial, full text, etc).

Remember to VACUUM ANALYZE this table from time to time,
so the planner can judge efficiently whether to use this new
index or not.

Use EXPLAIN ANALYZE SELECT .... to see whether the index
is really used.

> I don't care about optimising INSERT, DELETE and UPDATE queries, as they are
> only done at night when the load is very low.
> Thank you very much for any help,

Oh, they can benefit from the index anyhow. :)

Regards,
Dawid

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Dawid Kuroczko 2005-03-22 09:58:43 Re: What about utility to calculate planner cost constants?
Previous Message Layet Benjamin 2005-03-22 09:22:24 best practices with index on varchar column