From: Tom Lane <tgl@sss.pgh.pa.us>
To: Teju Jakkidi vlogs <teja.jakkidi05@gmail.com>
Cc: pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: Query taking long with levenshtein function
Date: Tue, 28 Feb 2023 18:30:51 -0500
Message-ID: <1278258.1677627051@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKA2XvZ_zFgfnavkEDMvfLtHzQeH-3qGROfAp+=CnrLF8TTvyQ@mail.gmail.com>
References: <CAKA2XvZ_zFgfnavkEDMvfLtHzQeH-3qGROfAp+=CnrLF8TTvyQ@mail.gmail.com>
Teju Jakkidi vlogs <teja.jakkidi05@gmail.com> writes:
> We have a query as below which uses the levenshtein function to compare
> strings.
> SELECT "name", levenshtein("name",'some string') as p FROM table1
> where levenshtein("name",'some string') <= 2 order by p desc;
> We have a GIST index built on top of this table as below:
> CREATE INDEX gist_idx ON table1 USING GIST("name");
AFAIK, that index is completely useless for this query. I don't
really see a good way to index it either --- "levenshtein distance
less than X" seems like a not very tractable requirement. Can
you formulate your matching rules some other way?
regards, tom lane
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, teja.jakkidi05@gmail.com, pgsql-admin@lists.postgresql.org
Subject: Re: Query taking long with levenshtein function
In-Reply-To: <1278258.1677627051@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