Re: planning issue - Mailing list pgsql-general

From John D. Burger
Subject Re: planning issue
Date
Msg-id B1EC5A65-282B-4CDF-9DE2-79A0EA84D1D2@mitre.org
Whole thread Raw
In response to Re: planning issue  (Jeff Davis <pgsql@j-davis.com>)
List 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


pgsql-general by date:

Previous
From: George Weaver
Date:
Subject: Re: DST problem on Windows Server
Next
From: Alban Hertroys
Date:
Subject: Planner tuning