pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Lewis <mlewis@entrata.com>
Cc: Ninad Shah <nshah.postgres@gmail.com>
Cc: balasubramanian c r <crbs.siebel@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Querying a table with jaccard similarity with 1.6 million records take 12 seconds
Date: Thu, 02 Sep 2021 15:44:09 -0400
Message-ID: <2266571.1630611849@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHOFxGruzhrb0SeD=5jLjgB+P-h3WpkbMyGfaje4Uuf_EVu5wQ@mail.gmail.com>
References: <CANnzXMPHf2r8ONRWodAMHskR86mB6z6ArmN+y636dn6qfvsL4g@mail.gmail.com>
	<CAOFEiBeo46Og+eTs5vyxcj7Gtck1MOE-VOae13WOhcrnmSf3aQ@mail.gmail.com>
	<CAHOFxGruzhrb0SeD=5jLjgB+P-h3WpkbMyGfaje4Uuf_EVu5wQ@mail.gmail.com>

Michael Lewis <mlewis@entrata.com> writes:
> This is showing many false positives from the index scan that get removed
> when the actual values are examined. With such a long search parameter,
> that does not seem surprising. I would expect a search on "raj nagar
> ghaziabad 201017" or something like that to yield far fewer results from
> the index scan. I don't know GIN indexes super well, but I would guess that
> including words that are very common will yield false positives that get
> filtered out later.

Yeah, the huge "Rows Removed" number shows that this index is very
poorly adapted to the query.  I don't think the problem is with GIN
per se, but with a poor choice of how to use it.  The given example
looks like what the OP really wants to do is full text search.
If so, a GIN index should be fine as long as you put tsvector/tsquery
filtering in front of it.  If that's not a good characterization of
the goal, it'd help to tell us what the goal is.  (Just saying "I
want to use jaccard similarity" sounds a lot like a man whose only
tool is a hammer, therefore his problem must be a nail, despite
evidence to the contrary.)

			regards, tom lane





view thread (8+ messages)  latest in thread

Message-ID: <2266571.1630611849@sss.pgh.pa.us>
Permalink:  ../2266571.1630611849@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2266571.1630611849@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 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: tgl@sss.pgh.pa.us, mlewis@entrata.com, nshah.postgres@gmail.com, crbs.siebel@gmail.com
  Subject: Re: Querying a table with jaccard similarity with 1.6 million records take 12 seconds
  In-Reply-To: <2266571.1630611849@sss.pgh.pa.us>
  References: <CANnzXMPHf2r8ONRWodAMHskR86mB6z6ArmN+y636dn6qfvsL4g@mail.gmail.com> <CAOFEiBeo46Og+eTs5vyxcj7Gtck1MOE-VOae13WOhcrnmSf3aQ@mail.gmail.com> <CAHOFxGruzhrb0SeD=5jLjgB+P-h3WpkbMyGfaje4Uuf_EVu5wQ@mail.gmail.com> <2266571.1630611849@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