From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Andrus" <eetasoft(at)online(dot)ee> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: How to force Postgres to use index on ILIKE |
Date: | 2006-06-06 14:23:55 |
Message-ID: | 16926.1149603835@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
"Andrus" <eetasoft(at)online(dot)ee> writes:
>> 1) why are you using CHAR and not VARCHAR or TEXT? CHAR will give you
>> problems using an index, period.
> 1. I haven't seen any example where VARCHAR is better that CHAR for indexing
The advice you were given is good, even if the explanation is bad.
CHAR(n) is a poor choice for just about every purpose, because of all
the padding blanks it insists on storing and transmitting. That adds
up to a lot of wasted space, I/O effort, and CPU cycles.
> I tried by Postgres does not use index. Why ?
> create index nimib2 on firma1.klient(lower(nimi) bpchar_pattern_ops);
Try to get over this fixation on CHAR. That would work with
text_pattern_ops --- lower() returns TEXT, and TEXT is what the LIKE
operator accepts, so that's the opclass you need to use to optimize
lower() LIKE 'pattern'.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2006-06-06 14:39:01 | Re: Some queries starting to hang |
Previous Message | Tom Lane | 2006-06-06 13:48:43 | Re: [PERFORM] psql -A (unaligned format) eats too much |