Re: Index selection (and partial index) for BYTEA field

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Index selection (and partial index) for BYTEA field
Date: 2004-03-19 15:40:43
Message-ID: 24545.1079710843@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com> writes:
> explain tells me it is using the partial index. But when I create
> partial index on the id column (BYTEA):
> create unique index i_partition_id_000 on partition(id)
> where id like '\\000%';

> explain select * from partition where id like '\\000\\001%';
> says the query is using the PK index, not the partial index. Why is this so?

The partial index matcher is not omniscient. It knows a few things
about btree-compatible comparison operators, but nothing about LIKE.
Accordingly, this partial index will only get matched to queries that
contain *exactly* "id like '\\000%'" in their WHERE clauses.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2004-03-19 15:49:27 Re: transactions in plpgsql
Previous Message Tom Lane 2004-03-19 15:17:02 Re: sequential scan when using bigint value