From: | David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Joe Conway <mail(at)joeconway(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Index selection (and partial index) for BYTEA field |
Date: | 2004-03-20 19:44:26 |
Message-ID: | 405C9F1A.5080409@zara.6.isreserved.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane wrote:
>>There's no way to force use of either index, but you can probably get
>>your partial index picked if you define the index like:
>>[ example ]
>
> Probably a more practical way is to generate redundant WHERE conditions.
> For instance:
>
> create index i_partition_id_000 on partition(id)
> where id like '\\000%';
> ... etc etc ...
>
> then when you really want to search for \000\001\002% you do:
>
> select * from partition
> where id like '\\000\\001\\002%' AND id like '\\000%';
>
> The second WHERE clause is redundant with the first, but it matches
> the partial index condition so that the index can be used.
That is one cool trick. And it worked!
--
dave
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Sherrill | 2004-03-20 23:08:21 | Re: Help needed with normalisation |
Previous Message | Gregory Wood | 2004-03-20 19:36:06 | Re: transactions in plpgsql |