Re: planning issue

From: "John D(dot) Burger" <john(at)mitre(dot)org>
To: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: planning issue
Date: 2007-03-19 14:50:53
Message-ID: B1EC5A65-282B-4CDF-9DE2-79A0EA84D1D2@mitre.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> create a function lower index and instead of calling ilike call ~
>> lower('123')
>
> To clarify a little:
>
> CREATE INDEX table_a_lower_field_1_idx on table_a ((lower(field_1)));
> CREATE INDEX table_a_lower_field_2_idx on table_a ((lower(field_2)));
> SELECT
> *
> FROM
> table_a
> WHERE
> id != 10001
> AND
> (
> ( lower(field_1) = '123' )
> OR
> ( lower(field_2) = 'abc' )
> )

To put my own two cents in, I always try to make sure I use lower()
in the query on everything I'm comparing, as Josh originally
suggested, so I would do this:

lower(field_2) = lower('abc')

This ensures that both sides of the comparison are being downcased
the same way - otherwise there might be a discrepancy due to
collation differences, etc., between the client and the server sides.

This seems silly in this example, but I think it's a good habit.

- John Burger
MITRE

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2007-03-19 14:55:43 Planner tuning
Previous Message George Weaver 2007-03-19 14:43:25 Re: DST problem on Windows Server