Re: Index not always being used

From: John Scalia <jayknowsunix(at)gmail(dot)com>
To: Holger Jakobs <holger(at)jakobs(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Index not always being used
Date: 2019-08-29 14:29:06
Message-ID: 8D7F747E-132E-4543-9933-583DE249850F@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Good to know, thanks

Sent from my iPad

> On Aug 29, 2019, at 10:22 AM, Holger Jakobs <holger(at)jakobs(dot)com> wrote:
>
> Hi,
>
> A good solution would be to add another B-Tree index. The planner would choose this one in case of a search using "=" and the trigram index when using "like", "similar to" or "~" (regexp).
>
> A trigram index is not suitable for a "=" comparison.
>
> Regards,
>
> Holger
>
>> Am 29.08.19 um 16:15 schrieb John Scalia:
>> I’ve got a table with approximately 5.5 million rows, and one column that is frequently searched is of type varchar(50) and we just put a trigram index on it. Now, if we search “where bld_city = ‘baskingridge’”, explain says a sequential table scan is going to be used, but if I change the query to use “where bold_city like ‘basking%’”, then explain correctly shows that a bitmap index scan will be performed. Why would these two forms use different approaches? I’m a bit confused.
>> —
>> Jay
>>
>> Sent from my iPad
>>
> --
> Holger Jakobs, Bergisch Gladbach
> instant messaging: xmpp:holger(at)jakobs(dot)com
> +49 178 9759012 oder +49 2202 817157

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Wells Oliver 2019-08-29 17:48:38 Blocking clients based on application name?
Previous Message Holger Jakobs 2019-08-29 14:22:36 Re: Index not always being used