Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p89rp-0001bR-4T for pgsql-general@arkaria.postgresql.org; Thu, 22 Dec 2022 00:55:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p89ro-000564-0h for pgsql-general@arkaria.postgresql.org; Thu, 22 Dec 2022 00:55:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p89rm-0004y0-2L for pgsql-general@lists.postgresql.org; Thu, 22 Dec 2022 00:55:23 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p89ri-000598-Bu for pgsql-general@lists.postgresql.org; Thu, 22 Dec 2022 00:55:21 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 1A11C3200919; Wed, 21 Dec 2022 19:55:16 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 21 Dec 2022 19:55:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=langille.org; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1671670515; x=1671756915; bh=zu6WmYSPL+ UsMVj5obqRy95fvCbQW1s43I0UiclmnfA=; b=Ww3NsxIoMQnb1k397n7SpZFriZ bcYCvwSMV7EY54xs0ikVQ4TNJvri+fF6b+q2cSpTeKUNjqnDb9b5wwhzh5JBH52y Zu5sMdMzwtvSBCkBO6lqZQV8fQ4O+450QTWbnF5Y3FGCxp2cMRjOcKa0LnXsqvPS wH/JfS/WKo+dv9frK9vvBGRavqdUlyJC5vuUKpcWgUIi3xS0BI60zn+WiBb39Rj4 7f4diUvp6e/WYUiJ+Qt2ply1t3ukt4r9/9ylOAxpP8N6bOcWB83FxM1kegataqHf /DQ55kmkqcSuUzC4L525+7GCO33g21IXTm3N7VUvSSSzFGJKbvo6NuE7RmdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1671670515; x=1671756915; bh=zu6WmYSPL+UsMVj5obqRy95fvCbQ W1s43I0UiclmnfA=; b=rm/P8m4ags665k8TCCn/Nl4rRKq02Z4yzKyXaXoDT5jP 6IRJ8e6nEWWXNYMhf6raiQbDWe6UtYggqtZuz1XMPxx+QSmE6u/ugyyhVx0ZtC0p r/mIu+t2IIQueEA9UvQJ6QEmF40/pwxnj8Ljl0JcTJaIA/8PouO0xTakI3v61mME DEj/0wBcz+dnYTjx5fV4vyciTu5L6jpKZxtNYttmWuW4Ex/VFzNpwRaSK1PPkVbS JX1E4XQ/0e2ntNuZllJk/aEqNA5T03QJMNsapFj3VXOz/VQaVlaRAL3cb3r4fy7o ft8dH/aAezsb7tt2wSdsGNmtCnsZev+NayIz3ZCBXw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeelgddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfevfhfhkffffgggjggtsegrtderredtfeejnecuhfhrohhmpeffrghnucfn rghnghhilhhlvgcuoegurghnsehlrghnghhilhhlvgdrohhrgheqnecuggftrfgrthhtvg hrnhepfeefieelgeffhfegjeeuhfffudeugeeuieehhfduteffhfetffehgedtjeekgfev necuffhomhgrihhnpehfrhgvshhhphhorhhtshdrohhrghdplhgrnhhgihhllhgvrdhorh hgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepuggr nheslhgrnhhgihhllhgvrdhorhhg X-ME-Proxy: Feedback-ID: ifbf9424e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Dec 2022 19:55:14 -0500 (EST) Subject: Re: tsvector not giving expected results on one host To: Oleg Bartunov Cc: Tom Lane , pgsql-general@lists.postgresql.org References: <2797dd29-aebb-43a2-9fd7-63bd77a944b2@app.fastmail.com> <9f89f00a-e400-4a9b-803b-f84999b6ffca@app.fastmail.com> <4006202.1671306931@sss.pgh.pa.us> <6ad40e1f-09dc-4002-8f54-0e2657137aef@app.fastmail.com> <5cd18dcb-c526-4c1f-ac4f-c56cfbdcd55e@app.fastmail.com> From: Dan Langille Message-ID: <50996900-18f9-31c5-5e3f-e6b26245f69b@langille.org> Date: Wed, 21 Dec 2022 19:55:13 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:52.0) Gecko/20100101 PostboxApp/7.0.59 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------19C6C013786A99EF0A9D62B6" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------19C6C013786A99EF0A9D62B6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Oleg Bartunov wrote on 12/21/22 12:31 PM: > I > > On Wed, Dec 21, 2022 at 1:12 PM Oleg Bartunov wrote: >> Dan, >> >> it's always good to specify configuration name in a query to avoid >> recheck, since >> websearch_to_tsquery(regconfig, text) is immutable, while >> websearch_to_tsquery(text) is stable. I am glad to hear this because one of my decisions was: * change the query to include configuration name * change the default configuration name I think I'm going to start using websearch_to_tsquery(regconfig, text) > immutable function calculates once in planning time, but stable > function calculates during running time, > so the difference may be very big depending on how many tuples found. Looking at my data, the largest tsvector collection has 453 elements. About 40 have more than 170.  Total number of rows is about 2400. Another issue discussed on IRC: why store my tsvector values? Why not just index them instead? At present: I have this column:  pkgmessage_textsearchable  | tsvector   |   |  | generated always as (to_tsvector('english'::regconfig, pkgmessage)) stored with this index: ports_pkgmessage_textsearchable_idx" gin (pkgmessage_textsearchable) Instead, I could replace that column and index with this index: "testing" gin (to_tsvector('english'::regconfig, pkgmessage)) Simple testing showed it was comparable if not slightly faster. The plan now: implement the index on to_tsvector, not a column, and start specifying the configuration. That's in the near future. I've written up this journey at https://news.freshports.org/2022/12/18/when-tsvector-was-working-as-expected-on-most-hosts-but-not-one/ thank you >> See the difference: >> >> [local]:5433 oleg@oleg=# explain (analyze,costs off) select title >> from apod where websearch_to_tsquery('simple','galaxies') @@ fts; >> QUERY PLAN >> --------------------------------------------------------------------------------------- >> Bitmap Heap Scan on apod (actual time=0.008..0.008 rows=0 loops=1) >> Recheck Cond: ('''galaxies'''::tsquery @@ fts) >> -> Bitmap Index Scan on gin_apod_fts_idx (actual time=0.007..0.007 >> rows=0 loops=1) >> Index Cond: (fts @@ '''galaxies'''::tsquery) >> Planning Time: 0.134 ms >> Execution Time: 0.022 ms >> (6 rows) >> >> Time: 0.369 ms >> [local]:5433 oleg@oleg=# explain (analyze,costs off) select title >> from apod where websearch_to_tsquery('galaxies') @@ fts; >> QUERY PLAN >> ----------------------------------------------------------------------------------------- >> Bitmap Heap Scan on apod (actual time=0.107..1.463 rows=493 loops=1) >> Filter: (websearch_to_tsquery('galaxies'::text) @@ fts) >> Heap Blocks: exact=276 >> -> Bitmap Index Scan on gin_apod_fts_idx (actual time=0.059..0.059 >> rows=493 loops=1) >> Index Cond: (fts @@ websearch_to_tsquery('galaxies'::text)) >> Planning Time: 0.125 ms >> Execution Time: 1.518 ms >> (7 rows) -- Dan Langille - dan@langille.org https://langille.org/ --------------19C6C013786A99EF0A9D62B6 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Oleg Bartunov wrote on 12/21/22 12:31 PM:
I

On Wed, Dec 21, 2022 at 1:12 PM Oleg Bartunov <obartunov@postgrespro.ru> wrote:
Dan,

it's always good to specify configuration name in a query to avoid
recheck,  since
websearch_to_tsquery(regconfig, text) is immutable, while
websearch_to_tsquery(text) is stable.

I am glad to hear this because one of my decisions was:

* change the query to include configuration name
* change the default configuration name

I think I'm going to start using websearch_to_tsquery(regconfig, text)
immutable function calculates once in planning time, but stable
function calculates during running time,
so the difference may be very big depending on how many tuples found.

Looking at my data, the largest tsvector collection has 453 elements.  About 40 have more
than 170.  Total number of rows is about 2400.

Another issue discussed on IRC: why store my tsvector values? Why not just index them instead?

At present: I have this column:

 pkgmessage_textsearchable  | tsvector   |   |  | generated always as (to_tsvector('english'::regconfig, pkgmessage)) stored

with this index: ports_pkgmessage_textsearchable_idx" gin (pkgmessage_textsearchable)

Instead, I could replace that column and index with this index:

"testing" gin (to_tsvector('english'::regconfig, pkgmessage))

Simple testing showed it was comparable if not slightly faster.

The plan now: implement the index on to_tsvector, not a column, and start specifying the configuration. That's in the near future.

I've written up this journey at https://news.freshports.org/2022/12/18/when-tsvector-was-working-as-expected-on-most-hosts-but-not-one/

thank you
See the difference:

[local]:5433 oleg@oleg=# explain (analyze,costs off)  select title
from apod where  websearch_to_tsquery('simple','galaxies') @@ fts;
                                      QUERY PLAN
---------------------------------------------------------------------------------------
 Bitmap Heap Scan on apod (actual time=0.008..0.008 rows=0 loops=1)
   Recheck Cond: ('''galaxies'''::tsquery @@ fts)
   ->  Bitmap Index Scan on gin_apod_fts_idx (actual time=0.007..0.007
rows=0 loops=1)
         Index Cond: (fts @@ '''galaxies'''::tsquery)
 Planning Time: 0.134 ms
 Execution Time: 0.022 ms
(6 rows)

Time: 0.369 ms
[local]:5433 oleg@oleg=# explain (analyze,costs off)  select title
from apod where  websearch_to_tsquery('galaxies') @@ fts;
                                       QUERY PLAN
-----------------------------------------------------------------------------------------
 Bitmap Heap Scan on apod (actual time=0.107..1.463 rows=493 loops=1)
   Filter: (websearch_to_tsquery('galaxies'::text) @@ fts)
   Heap Blocks: exact=276
   ->  Bitmap Index Scan on gin_apod_fts_idx (actual time=0.059..0.059
rows=493 loops=1)
         Index Cond: (fts @@ websearch_to_tsquery('galaxies'::text))
 Planning Time: 0.125 ms
 Execution Time: 1.518 ms
(7 rows)
--------------19C6C013786A99EF0A9D62B6--