Received: from malur.postgresql.org ([217.196.149.56])
by arkaria.postgresql.org with esmtps (TLS1.3) tls
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
(Exim 4.94.2)
(envelope-from )
id 1vGYic-000bjZ-38
for pgsql-performance@arkaria.postgresql.org; Wed, 05 Nov 2025 08:18:14 +0000
Received: from localhost ([127.0.0.1] helo=malur.postgresql.org)
by malur.postgresql.org with esmtp (Exim 4.94.2)
(envelope-from )
id 1vGYia-001627-7n
for pgsql-performance@arkaria.postgresql.org; Wed, 05 Nov 2025 08:18:11 +0000
Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29])
by malur.postgresql.org with utf8esmtps (TLS1.3) tls
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
(Exim 4.94.2)
(envelope-from )
id 1vGYiZ-00161y-PE
for pgsql-performance@lists.postgresql.org; Wed, 05 Nov 2025 08:18:10 +0000
Received: from outbound.visena.net ([46.226.12.34])
by magus.postgresql.org with utf8esmtps (TLS1.3) tls
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
(Exim 4.96)
(envelope-from )
id 1vGYiW-0065AZ-1j
for pgsql-performance@lists.postgresql.org;
Wed, 05 Nov 2025 08:18:10 +0000
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=visena.com;
s=20141101.wh; h=Content-Type:MIME-Version:Subject:Message-ID:To:From:Date:
Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description;
bh=AF1CKU6La18aLDfWB4EissX5gnjGgKOIqMjDIOqbrpI=; b=gpSNHUS4m95Oz/dLwq47pWhGa
aUTFOZJfAFP2Qr/zCPVxbEUa3Lm5pkgDUSYdTgnmrNF30kwngEv+bHb67LQZNeN2zkxCoQs5NHubG
aF29T61rt+Sq0r3m674xedjUkHYsZEqavrjo8EoyFfiySL+g1Ejy9vvpGSOc2EiVpHu2A=;
Received: from batch01.services.internal.visena.net ([10.3.0.103])
by outbound.visena.net with utf8esmtp (Exim 4.93)
(envelope-from )
id 1vGYiV-002SXK-1d
for pgsql-performance@lists.postgresql.org; Wed, 05 Nov 2025 09:18:07 +0100
Date: Wed, 5 Nov 2025 09:18:06 +0100 (CET)
From: Andreas Joseph Krogh
To: pgsql-performance@lists.postgresql.org
Message-ID:
Subject: trgm and index-usage when using similarity function
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_231756_1120951262.1762330686943"
X-Mailer: Visena Mail 3.3.1170
List-Id:
List-Help:
List-Subscribe:
List-Post:
List-Owner:
List-Archive:
Archived-At:
Precedence: bulk
------=_Part_231756_1120951262.1762330686943
Content-Type: multipart/related;
boundary="----=_Part_231757_1812023446.1762330686943"
------=_Part_231757_1812023446.1762330686943
Content-Type: multipart/alternative;
boundary="----=_Part_231758_1465039356.1762330686970"
------=_Part_231758_1465039356.1762330686970
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Using PG-18.0, I'm having problems with trgm and index-usage when using=20
similarity-function.
Given the following schema:
CREATE TABLE person
(
entity_id BIGSERIAL PRIMARY KEY,
firstname text,
lastname text,
fullname_search text,
birthdate date
);
INSERT INTO person
SELECT pers.entity_id, pers.firstname, pers.lastname, pers.fullname_search,=
=20
pers.birthdate
FROM onp_crm_person pers;
CREATE INDEX test_idx_onp_crm_person_duplicates
ON person USING gin (fullname_search gin_trgm_ops)
;
This query uses index and is fast, but I have to set=20
pg_trgm.similarity_threshold manually first:
SET pg_trgm.similarity_threshold =3D 0.9;
EXPLAIN (ANALYZE, BUFFERS)
SELECT p.entity_id, p.firstname, p.lastname, p.fullname_search, p.birthdate
FROM person p
WHERE EXISTS (
SELECT *
FROM person d
WHERE d.fullname_search % p.fullname_search
AND d.entity_id <> p.entity_id
LIMIT 1
)
;
=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90
=E2=94=82 QUERY PLAN =E2=94=82
=E2=94=9C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=A4
=E2=94=82 Nested Loop Semi Join (cost=3D2.19..319906.05 rows=3D256 width=3D=
45) (actual=20
time=3D29.527..2626.465 rows=3D7497.00 loops=3D1) =E2=94=82
=E2=94=82 Buffers: shared hit=3D972919 =E2=94=82
=E2=94=82 -> Seq Scan on person p (cost=3D0.00..488.81 rows=3D25581 width=
=3D45) (actual=20
time=3D0.024..1.127 rows=3D25581.00 loops=3D1) =E2=94=82
=E2=94=82 Buffers: shared hit=3D233 =E2=94=82
=E2=94=82 -> Bitmap Heap Scan on person d (cost=3D2.19..10.03 rows=3D256 wi=
dth=3D25) (actual=20
time=3D0.102..0.102 rows=3D0.29 loops=3D25581) =E2=94=82
=E2=94=82 Recheck Cond: (fullname_search % p.fullname_search) =E2=94=82
=E2=94=82 Rows Removed by Index Recheck: 0 =E2=94=82
=E2=94=82 Filter: (entity_id <> p.entity_id) =E2=94=82
=E2=94=82 Rows Removed by Filter: 1 =E2=94=82
=E2=94=82 Heap Blocks: exact=3D34252 =E2=94=82
=E2=94=82 Buffers: shared hit=3D972686 =E2=94=82
=E2=94=82 -> Bitmap Index Scan on test_idx_onp_crm_person_duplicates (cost=
=3D0.00..2.13=20
rows=3D256 width=3D0) (actual time=3D0.097..0.097 rows=3D1.99 loops=3D25581=
) =E2=94=82
=E2=94=82 Index Cond: (fullname_search % p.fullname_search) =E2=94=82
=E2=94=82 Index Searches: 25581 =E2=94=82
=E2=94=82 Buffers: shared hit=3D933853 =E2=94=82
=E2=94=82 Planning: =E2=94=82
=E2=94=82 Buffers: shared hit=3D2 =E2=94=82
=E2=94=82 Planning Time: 3.620 ms =E2=94=82
=E2=94=82 JIT: =E2=94=82
=E2=94=82 Functions: 7 =E2=94=82
=E2=94=82 Options: Inlining false, Optimization false, Expressions true, De=
forming=20
true =E2=94=82
=E2=94=82 Timing: Generation 0.772 ms (Deform 0.230 ms), Inlining 0.000 ms,=
=20
Optimization 5.522 ms, Emission 23.219 ms, Total 29.513 ms =E2=94=82
=E2=94=82 Execution Time: 2628.643 ms =E2=94=82
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98
(23 rows)
But using similarity-function:
EXPLAIN (ANALYZE, BUFFERS)
SELECT p.entity_id, p.firstname, p.lastname, p.fullname_search, p.birthdate
FROM person p
WHERE EXISTS (
SELECT *
FROM person d
WHERE similarity(d.fullname_search, p.fullname_search) >=3D 0.9
AND d.entity_id <> p.entity_id
LIMIT 1
)
;
=E2=80=A6 this has been running for 30 minutes now and I've cancelled it.
Any suggestions on how to fix this query so I can:
*=20
specify the similarity-factor as part of the query
*=20
Make it fast
Thanks.
--
Andreas Joseph Krogh
------=_Part_231758_1465039356.1762330686970
Content-Type: text/html;charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Using PG-18.0, I'm having problems with trgm and index-=
usage when using similarity-function.
=C2=A0
Given the following schema:
CREATE TABLE person
(
enti=
ty_id BIGSERIAL PRIMARY KEY=
,
firstname =
text,
lastname <=
strong>text,
fullname=
_search text,=
birthdate date
);
INSERT INTO person
SELECT pers.entity_id, pers.firstname, pers.lastname, pers.fu=
llname_search, pers.birthdate<=
br>FROM onp_crm_person pers;
CREATE INDEX test_idx_o=
np_crm_person_duplicates
ON <=
/strong>person USING gin (fullname_search gin_trgm=
_ops)
;
=C2=A0
<=
p class=3D"visenaNormal">This query uses index and is fast, but I have to s=
et pg_trgm.similarity_threshold manually first:
SET pg_trgm.similarity_threshold =
strong>=3D 0.9;
EXPLAIN (ANALYZE, BUFFERS)
SELECT p.entity_id,=
p.firstname, p.lastname, p.fullname_search=
, p.birthdate
FROM person p
WHERE EXISTS (
SELECT =
*
FROM person d=
WHERE d.fullname_search % p.fullname_search
AND d.entity_id =
span><> p.entity_id=
span>
LIMIT 1
)
;
=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=90
=E2=94=82 =
QUERY PLAN =
=E2=94=82
=E2=94=9C=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=A4
=E2=94=82 Nested Loop Semi Join (cost=3D2.19..319=
906.05 rows=3D256 width=3D45) (actual time=3D29.527..2626.465 rows=3D7497.0=
0 loops=3D1) =E2=94=82
=E2=94=82 =
Buffers: shared hit=3D972919 =
=
=E2=94=82
=E2=94=82 -> Seq Scan on person p (cost=3D0.00..488.=
81 rows=3D25581 width=3D45) (actual time=3D0.024..1.127 rows=3D25581.00 loo=
ps=3D1) =E2=94=82
=E2=94=82 =
Buffers: shared hit=3D233 =
=E2=
=94=82
=E2=94=82 -> Bitmap Heap Scan on person d (cost=3D2.19..10=
.03 rows=3D256 width=3D25) (actual time=3D0.102..0.102 rows=3D0.29 loops=3D=
25581) =E2=94=82
=E2=94=82 Rechec=
k Cond: (fullname_search % p.fullname_search) =
=E2=94=82=E2=94=82 Rows Removed by Index Recheck: 0 =
=
=E2=94=82
=E2=94=82 Filter: (entity_id <> p=
.entity_id) =
=E2=94=82
=E2=94=82 =
Rows Removed by Filter: 1 =
=
=E2=94=82
=E2=94=82 Heap Blocks: exact=3D34252 =
=
=E2=94=82
=E2=94=82 Buffers: shared =
hit=3D972686 =
=E2=94=82
=E2=94=
=82 -> Bitmap Index Scan on test_idx_onp_crm_person_duplicates =
(cost=3D0.00..2.13 rows=3D256 width=3D0) (actual time=3D0.097..0.097 rows=
=3D1.99 loops=3D25581) =E2=94=82
=E2=94=82 Index Cond: (fu=
llname_search % p.fullname_search) =
=E2=94=82
=E2=94=82 =
Index Searches: 25581 =
=
=E2=94=82
=E2=94=82 Buffers: shared hit=3D933853 =
=
=E2=94=82
=E2=94=82 Planning: =
=
=E2=94=82
=E2=94=
=82 Buffers: shared hit=3D2 =
=
=E2=94=82
=E2=94=82 Planning Time: 3.620 ms =
=
=E2=94=82
=E2=94=82 JIT: =
=
=E2=94=82
=
=E2=94=82 Functions: 7 =
=
=E2=94=82
=E2=94=82 Options: Inlining false, Optimization=
false, Expressions true, Deforming true =
=E2=94=82
=E2=94=82 Timing: Gen=
eration 0.772 ms (Deform 0.230 ms), Inlining 0.000 ms, Optimization 5.522 m=
s, Emission 23.219 ms, Total 29.513 ms =E2=94=82<=
br>=E2=94=82 Execution Time: 2628.643 ms =
=
=E2=94=82
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=
=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=98
(23 rows)
=C2=A0
But using similarity-function:
=
EXPLAIN (ANA=
LYZE, BUFFERS)
SELECT p.entity_id, p.firstname, p.lastname, p.fullname_search, p.birthdate
FROM person p
WHERE EXISTS (
SELECT *
<=
span style=3D"color:#000080;">FROM person d
W=
HERE similarity(d.fullname_search, p.fullname_search) >=3D 0.9
AND d.entity_id <> p.entity=
_id
=
LIMIT 1
)
;
=E2=80=A6 this has been running for 30 minutes now and I've cancelled =
it.
=C2=A0
Any su=
ggestions on how to fix this query so I can:
specify the similarity-factor as part of the query
Make it fast
Th=
anks.
=C2=A0
------=_Part_231758_1465039356.1762330686970--
------=_Part_231757_1812023446.1762330686943--
------=_Part_231756_1120951262.1762330686943--