Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibKuz-0003h0-8F for pgsql-general@arkaria.postgresql.org; Sun, 01 Dec 2019 08:49:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ibKuv-0000Ve-FI for pgsql-general@arkaria.postgresql.org; Sun, 01 Dec 2019 08:49:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibKuu-0000VR-OY for pgsql-general@lists.postgresql.org; Sun, 01 Dec 2019 08:49:20 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ibKun-0005kl-Dr for pgsql-general@lists.postgresql.org; Sun, 01 Dec 2019 08:49:19 +0000 Received: by mail-wr1-x442.google.com with SMTP id q10so4065574wrm.11 for ; Sun, 01 Dec 2019 00:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:mime-version:date:from:subject:thread-topic:to :content-transfer-encoding; bh=8gg+95r1pli+MFIMqKWW+ZWDsMSJAdxoYje7MhM//3A=; b=l+/XYAEinGTNFNNhwoKoILHG6b6xoo8r0AY1t4B+s2Jg4vmoJkP+tP0YwEAPsIF/pB KsGwY3f023ftrHKYQJecaO2DVpBKXv04N7g5qLwO5toSjVW3uPg8wNNkHD2dPy3DHKrx aKQ4oCzGdYeU6Z/xfgSKPAs3ohDZ+/Mcj1iGxiigqEFxux/MWjSgTuk8WkYsbys8kWUz MWJxvdtKdFoCOh/ZKAdsouaN8Xgx9WiS0L/QNk2c89ukToIsRx8oG+MRgXnWBHZartQf /hGOri/a/W2W9kP7ozorG1WI76uX3Mu5h4+ew7FRHx8+op/hrzzh7r/DXZ6zZ1e6mqJ2 Au8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version:date:from:subject :thread-topic:to:content-transfer-encoding; bh=8gg+95r1pli+MFIMqKWW+ZWDsMSJAdxoYje7MhM//3A=; b=SngFj6m53JJ+IAzez2GSATSC9Q+/5JbmCuQlPitLdnrmasORegmecs0wjVQv4Yarsp 4s5vGrklzloRT+SflERCAqS4KZM7RFQaq2naXC3A657aJVz8kjdlOmL2iD0iUv8XNt1x DPWieEmeU9GW+QXKE9gEGPJ4wGM0lgDnjwMnDaq4W8IIikPgg1d2vrhY63MDb0MPbU02 GiGjYMXr+XOESuZEIg7zHxIPTKhJi38ST0Y+3Sm5HyjSkr93T3wXHyBQ1eHBTVyRzBnK q8JwVZ57CRJrarCS+kD+nb4OalfP7WYyiOMAfH/9knk/FV9g8JZkbVKa1JMbaqkOBRhz 0bIw== X-Gm-Message-State: APjAAAUwlmyu6qmBI3qvnNkn18q5MHbt7vfOrLJjpZT1iJlMsTvFQkcf pPKTzxPRYh8JuURAlLS1uLQ= X-Google-Smtp-Source: APXvYqwD2RVNepaleCDrjMtdwE2Q6a1CuKjGQcraRcirBZY3CZLpXzb2BNqf/VR+ZXfjpcw8uGyz+A== X-Received: by 2002:adf:fd07:: with SMTP id e7mr11862602wrr.21.1575190150215; Sun, 01 Dec 2019 00:49:10 -0800 (PST) Received: from smtp.gmail.com ([46.211.147.37]) by smtp.gmail.com with ESMTPSA id z11sm5683773wrt.82.2019.12.01.00.49.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Dec 2019 00:49:09 -0800 (PST) Message-ID: <5de37e85.1c69fb81.ac277.b2fa@mx.google.com> MIME-Version: 1.0 Date: Sun, 1 Dec 2019 10:49:03 +0200 From: Dmytro Zhluktenko Subject: RE: Re: Re: Postgres Full Text Search Jsonb Array column does not search for first row Thread-Topic: RE: Re: Re: Postgres Full Text Search Jsonb Array column does not search for first row To: Laurenz Albe , "pgsql-general@lists.postgresql.org" Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk

The issue was solve= d with the approach suggested here.

https://stackoverflow= .com/questions/59049873/postgres-full-text-search-jsonb-array-column-does-n= ot-show-first-row

 

BR, Dmytro.

 

From: Laurenz Albe
Sent: 28 =D0=BB= =D0=B8=D1=81=D1=82=D0=BE=D0=BF=D0=B0=D0=B4=D0=B0 2019 =D1=80. 16:39
T= o: Dmytro Zhluktenko; pgsql-general@lists.postgres= ql.org
Subject: Re: Re: Postgres Full Text Search Jsonb Array= column does not search for first row

&n= bsp;

On Wed, 2019-11-27 at 11:54 +0200, Dmytr= o Zhluktenko wrote:

> explain (analyze, BUFFERS)=

> SELECT *

> FROM &q= uot;cp"."Repro" x where cp.make_tsvector(x) @@ 'fir:*'::tsqu= ery

>

> outputs this= query plan:

> Bitmap Heap Scan on "Repro&q= uot; x=C2=A0 (cost=3D12.00..16.26 rows=3D1 width=3D72) (actual time=3D0.007= .0.007 rows=3D0 loops=3D1)

>=C2=A0=C2=A0 Rechec= k Cond: (cp.make_tsvector(x.*) @@ '''fir'':*'::tsquery)

>=C2=A0=C2=A0 Buffers: shared hit=3D2

>= =C2=A0=C2=A0 ->=C2=A0 Bitmap Index Scan on repro_fts_idx=C2=A0 (cost=3D0= .00..12.00 rows=3D1 width=3D0) (actual time=3D0.005..0.005 rows=3D0 loops= =3D1)

>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 Index Cond: (cp.make_tsvector(x.*) @@ '''fir'':*'::tsquery)

>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Buf= fers: shared hit=3D2

> Planning Time: 0.070 ms

> Execution Time: 0.040 ms

>

> Query runs fine if uses seq scan. Seq = Scan is not desired here since this is the query that should run on huge am= ounts of data and it should find the first element.

> Obviously, if seq_scan is off, then query still does the same result.=

>

> Also, if you ad= d 100000 more entries, it will still fail to find the first one using index= .

 

I canno= t quite follow.

 

We have seen that the query can use the index by setting "enabl= e_seqscan =3D off",

but that PostgreSQL prefer= s to use a sequential scan because the table is small.

 

If the table were bigger, Pos= tgreSQL would prefer the index scan.

 

Are your concerns hypothetical or real?

If real, can you show EXPLAIN (ANALYZE, BUFFERS) output of= a query

execution where PostgreSQL chooses a seque= ntial scan, but you think

it shouldn't?

 

Yours,

Laurenz Albe

--

Cybertec | https://www.cybertec-postgresql.com

<= o:p> 

 

= =