Re: Re: Re: LIKE and indexes? - Mailing list pgsql-general

From Tom Lane
Subject Re: Re: Re: LIKE and indexes?
Date
Msg-id 15863.984695885@sss.pgh.pa.us
Whole thread Raw
In response to Re: Re: LIKE and indexes?  (Alexander Jerusalem <alexander.jerusalem@pop.chello.at>)
Responses Re: Re: Re: LIKE and indexes?
List pgsql-general
Alexander Jerusalem <alexander.jerusalem@pop.chello.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

pgsql-general by date:

Previous
From: Ben
Date:
Subject: Re: Re: Re: LIKE and indexes?
Next
From: Alexander Jerusalem
Date:
Subject: Re: Re: Re: LIKE and indexes?