Re: Plan differences - Mailing list pgsql-performance

From Tom Lane
Subject Re: Plan differences
Date
Msg-id 10594.1451574122@sss.pgh.pa.us
Whole thread Raw
In response to Plan differences  (Anton Melser <melser.anton@gmail.com>)
Responses Re: Plan differences  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Re: Plan differences  (Anton Melser <melser.anton@gmail.com>)
List pgsql-performance
Anton Melser <melser.anton@gmail.com> writes:
> I moved a DB between two "somewhat" similar Postgres installs and am
> getting much worse plans on the second. The DB was dumped via pg_dump
> (keeping indexes, etc.) and loaded to the new server.

> [ "like 'foo%'" is not getting converted into index bounds ]

I'd bet your old database is in C locale and the new one is not.

The LIKE optimization requires an index that's sorted according to plain
C (strcmp) rules.  A regular text index will be that way only if the
database's LC_COLLATE is C.

If you don't want to rebuild the whole database, you can create indexes to
support this by declaring them with COLLATE "C", or the older way is to
declare them with text_pattern_ops as the index opclass.

            regards, tom lane


pgsql-performance by date:

Previous
From: Anton Melser
Date:
Subject: Re: Plan differences
Next
From: Jim Nasby
Date:
Subject: Re: Plan differences