pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dan Langille <dan@langille.org>
To: Oleg Bartunov <obartunov@postgrespro.ru>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: tsvector not giving expected results on one host
Date: Wed, 21 Dec 2022 19:55:13 -0500
Message-ID: <50996900-18f9-31c5-5e3f-e6b26245f69b@langille.org> (raw)
In-Reply-To: <CAF4Au4zY9nA27diCUgg_=e+R5y5Xj0hLiTzh9yLSzw4kTpyuOA@mail.gmail.com>
References: <2797dd29-aebb-43a2-9fd7-63bd77a944b2@app.fastmail.com>
	<9f89f00a-e400-4a9b-803b-f84999b6ffca@app.fastmail.com>
	<4006202.1671306931@sss.pgh.pa.us>
	<e8c6d7f1-afcd-44e4-a0ff-c283c104aad7@app.fastmail.com>
	<6ad40e1f-09dc-4002-8f54-0e2657137aef@app.fastmail.com>
	<5cd18dcb-c526-4c1f-ac4f-c56cfbdcd55e@app.fastmail.com>
	<CAF4Au4x0UmiJDXVecFxPhhX2dApXFeQg0y4TCEv08-7hJPJ-cg@mail.gmail.com>
	<CAF4Au4zY9nA27diCUgg_=e+R5y5Xj0hLiTzh9yLSzw4kTpyuOA@mail.gmail.com>

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-o...

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/

view thread (9+ messages)

Message-ID: <50996900-18f9-31c5-5e3f-e6b26245f69b@langille.org>
Permalink:  ../50996900-18f9-31c5-5e3f-e6b26245f69b@langille.org/
Also on:    postgresql.org/message-id/50996900-18f9-31c5-5e3f-e6b26245f69b@langille.org

 · 

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: dan@langille.org, obartunov@postgrespro.ru, tgl@sss.pgh.pa.us
  Subject: Re: tsvector not giving expected results on one host
  In-Reply-To: <50996900-18f9-31c5-5e3f-e6b26245f69b@langille.org>
  References: <2797dd29-aebb-43a2-9fd7-63bd77a944b2@app.fastmail.com> <9f89f00a-e400-4a9b-803b-f84999b6ffca@app.fastmail.com> <4006202.1671306931@sss.pgh.pa.us> <e8c6d7f1-afcd-44e4-a0ff-c283c104aad7@app.fastmail.com> <6ad40e1f-09dc-4002-8f54-0e2657137aef@app.fastmail.com> <5cd18dcb-c526-4c1f-ac4f-c56cfbdcd55e@app.fastmail.com> <CAF4Au4x0UmiJDXVecFxPhhX2dApXFeQg0y4TCEv08-7hJPJ-cg@mail.gmail.com> <CAF4Au4zY9nA27diCUgg_=e+R5y5Xj0hLiTzh9yLSzw4kTpyuOA@mail.gmail.com> <50996900-18f9-31c5-5e3f-e6b26245f69b@langille.org>

* 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