Re: Query taking seq scan on a table

From: Shrikant Bhende <shrikantpostgresql(at)gmail(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Avinash Kumar <avinash(dot)vallarapu(at)gmail(dot)com>, dbatoCloud Solution <dbatocloud17(at)gmail(dot)com>, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Query taking seq scan on a table
Date: 2020-09-22 12:59:19
Message-ID: CAMTQpJCguViOXL5kY=h90u40iS3MkRzLS39umnNYcQDLoFZ9oA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Jeff,

Thanks for the update.

*create index concurrently lname_test_btree_txt_pat_ops on wldbowner.member
(lname text_pattern_ops) where fname like LOWER(unaccent_string(lname) ||
'%')*

Is this the correct way to create a b-tree index with text_pattern_ops for
my requirement ?

Thanks

On Mon, Sep 21, 2020 at 8:01 PM Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:

> On Mon, Sep 21, 2020 at 12:51 AM Shrikant Bhende <
> shrikantpostgresql(at)gmail(dot)com> wrote:
>
>> Also I have tried to add a GIN index for better text search as below,
>>
>> CREATE INDEX idx_fnmae_lname_gin_composite ON wldbowner.member USING gin
>> (lower((((fname)::text || ' '::text) || (lname)::text))
>> rdsadmin.gin_trgm_ops);
>>
>
>
> You index does not match your query:
>
> ((lower(unaccent_string((lname)::text)) ~~ 'info%'::text) AND
> (lower(unaccent_string((fname)::text)) ~~ 'travel%'::text))
>
> Your index is not passing the columns through unaccent_string, and it is
> concatenating the columns while the query is treating them separately. You
> need to make the index (or indexes, as you might want one for each column)
> match the query.
>
> If the wildcard is always at the end of the search-pattern strings, you
> could instead use btree indexes with text_pattern_ops.
>
> Cheers,
>
> Jeff
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Hannah Huang 2020-09-22 13:10:50 Re: Cannot allocate memory
Previous Message JOIGNY Michael @Neteven 2020-09-22 08:20:58 Re: Cannot allocate memory