Re: Re: Re: LIKE and indexes?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Jerusalem <alexander(dot)jerusalem(at)pop(dot)chello(dot)at>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Re: LIKE and indexes?
Date: 2001-03-15 22:38:05
Message-ID: 15863.984695885@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexander Jerusalem <alexander(dot)jerusalem(at)pop(dot)chello(dot)at> writes:
> The query I'm analyzing is this one:

> SELECT count(*) from Person WHERE Person.pc_Id in (select pcpc.pc_fromid
> from pcpc inner join corporation on pcpc.pc_toid = corporation.pc_id where
> corporation.crp_name1 ilike 'Uni%');
^^^^^

Case-insensitive compares cannot use indexes in Postgres, because our
indexes are case-sensitive.

You could make an index on lower(crp_name1) and then do

... where lower(corporation.crp_name1) like 'uni%'

Actually, though, I don't believe that the lack of an indexscan on
corporation is the problem here. That's a tiny table and it's only
going to be scanned once in this plan. The real problem is the WHERE
... IN at the top level. Try changing to a WHERE EXISTS (see the PG
FAQ).

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephane 2001-03-15 22:45:33 troubles with libpq++
Previous Message Ben 2001-03-15 22:34:40 Re: Re: Re: LIKE and indexes?