pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alban Hertroys <haramrae@gmail.com>
To: aman gupta <amangpt89@gmail.com>
Cc: pgadmin-hackers@lists.postgresql.org
Cc: pgsql-general@lists.postgresql.org
Cc: manoj.t.kumar@ericsson.com
Cc: rajesh.tiwari@ericsson.com
Subject: Re: Optimizing Postgresql ILIKE while query
Date: Mon, 22 Oct 2018 09:23:35 +0200
Message-ID: <89E1AC86-A512-4396-A227-3E951477876D@gmail.com> (raw)
In-Reply-To: <CAC=C=veOiz2vo35uEhGhhq2YMmXcGj_ciA1S5hXDS3kCOq-zkA@mail.gmail.com>
References: <CAC=C=veOiz2vo35uEhGhhq2YMmXcGj_ciA1S5hXDS3kCOq-zkA@mail.gmail.com>



> On 22 Oct 2018, at 7:56, aman gupta <amangpt89@gmail.com> wrote:
> 
> Issue:
> 
> We have the base table which contains 22M records and we created a view on top of it while querying the view with ILIKE clause it took 44 seconds and with LIKE Clause 20 Seconds
> 
> Query:
> 
> fm_db_custom_db=# EXPLAIN (ANALYZE, TIMING OFF)
> select destination,hostname,inputfilename,inputtime,logicalservername,outputfilename,outputtime,processinglink,source,totalinputbytes,totalinputcdrs,totaloutputbytes,totaloutputcdrs from mmsuper.test_20m_view  where inputfilename ilike '%SDPOUTPUTCDR_4001_BLSDP09_ADM_4997_18-10-15-02549.ASN%';

Perhaps, when you have a question about timing, you shouldn't turn off the timing in the query plan? Now we can't see where the time is spent.

> <LIKE_Clause_ILIKE_Clause_Postgres_Response.txt>

That's all sequential scans that each remove a significant amount of rows. That probably costs a significant amount of time to do.

It looks like you don't have any indices on the underlying table(s) at all. I'd start there and then look at the ILIKE problem again. By that time, Pavel's suggestion for a trigram index on that text field is probably spot-on.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.





view thread (4+ messages)  latest in thread

Message-ID: <89E1AC86-A512-4396-A227-3E951477876D@gmail.com>
Permalink:  ../89E1AC86-A512-4396-A227-3E951477876D@gmail.com/
Also on:    postgresql.org/message-id/89E1AC86-A512-4396-A227-3E951477876D@gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: haramrae@gmail.com, amangpt89@gmail.com, pgadmin-hackers@lists.postgresql.org, manoj.t.kumar@ericsson.com, rajesh.tiwari@ericsson.com
  Subject: Re: Optimizing Postgresql ILIKE while query
  In-Reply-To: <89E1AC86-A512-4396-A227-3E951477876D@gmail.com>
  References: <CAC=C=veOiz2vo35uEhGhhq2YMmXcGj_ciA1S5hXDS3kCOq-zkA@mail.gmail.com> <89E1AC86-A512-4396-A227-3E951477876D@gmail.com>

* 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