pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Shrikant Bhende <shrikantpostgresql@gmail.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: Avinash Kumar <avinash.vallarapu@gmail.com>
Cc: dbatoCloud Solution <dbatocloud17@gmail.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: Query taking seq scan on a table
Date: Tue, 22 Sep 2020 10:07:26 -0400
Message-ID: <1176451.1600783646@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMTQpJCguViOXL5kY=h90u40iS3MkRzLS39umnNYcQDLoFZ9oA@mail.gmail.com>
References: <CAMTQpJA7eNEXJuLk=Yu5ubo0Wp8xYRwFzzpghRshDYCYPmJHJQ@mail.gmail.com>
	<CAN0TujdziL1CD7FFwKogObZSoe-b1rLLHUPc9m-H+GNbLm5naQ@mail.gmail.com>
	<CAMTQpJCrPLcbw6vmR2i8S6qbXVG3bLioTG7aCBm1JkBHoFtmrw@mail.gmail.com>
	<CAN0TujdQdT=H2EUAQLXzC0Pkc+zhoFyXFj3ayA4t4uz4sokPnw@mail.gmail.com>
	<CAMTQpJBgo03JVO1fRnmMDqsqQZJ-NsuubRL3EyXjKj4UU0v0YQ@mail.gmail.com>
	<CAMkU=1zeEd2Q1yLKBDaKC1DW1UVxtYJiAX+ifp6mwodTOGqCnw@mail.gmail.com>
	<CAMTQpJCguViOXL5kY=h90u40iS3MkRzLS39umnNYcQDLoFZ9oA@mail.gmail.com>

Shrikant Bhende <shrikantpostgresql@gmail.com> writes:
> *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 ?

No.  What you're trying to optimize is

                            Filter: ((lower(unaccent_string((lname)::text))
~~ 'info%'::text) AND (lower(unaccent_string((fname)::text)) ~~
'travel%'::text))

so you need one or both of

create index on member (lower(unaccent_string(lname)) text_pattern_ops);
create index on member (lower(unaccent_string(fname)) text_pattern_ops);

If one of those two conditions is reliably more selective than the
other, perhaps just one index would do.

			regards, tom lane





view thread (12+ messages)  latest in thread

Message-ID: <1176451.1600783646@sss.pgh.pa.us>
Permalink:  ../1176451.1600783646@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1176451.1600783646@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, shrikantpostgresql@gmail.com, jeff.janes@gmail.com, avinash.vallarapu@gmail.com, dbatocloud17@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: Query taking seq scan on a table
  In-Reply-To: <1176451.1600783646@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox