Re: Plan differences

From: Anton Melser <melser(dot)anton(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Plan differences
Date: 2015-12-31 20:10:12
Message-ID: CAKywjPrWq7-Mj_NEk8U5Yrrt9O3F_qj_iSgbw1PYRZ=gZFXLwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

Remind me never to never bet against you :-).

> 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.
>

Declaring new indexes with COLLATE "C" and removing the old indexes fixed
the like problem but it created a another - the > and < queries need a sort
before passing off the the new index. Having two indexes seems to give me
the best of both worlds, though obviously it's taking up (much) more space.
As space isn't ever likely to be a problem, and there are no updates (only
copy) to these tables, I'll keep it like this to avoid having to reload the
entire DB.

Thanks very much for your help.
Cheers,
Anton

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Anton Melser 2016-01-01 17:13:06 Re: Plan differences
Previous Message Tom Lane 2015-12-31 17:11:15 Re: Plan differences