Re: Index-only scan for btree_gist turns bpchar to char

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Index-only scan for btree_gist turns bpchar to char
Date: 2022-01-05 05:00:00
Message-ID: 9e09d032-298e-d57d-31a0-7984981851d9@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

04.01.2022 22:19, Tom Lane wrote:
> Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
>> While testing the index-only scan fix, I've discovered that replacing
>> the index-only scan with the index scan changes contrib/btree_gist
>> output because index-only scan for btree_gist returns a string without
>> padding.
> Ugh, yeah. This seems to be because gbt_bpchar_compress() strips
> trailing spaces (using rtrim1) before storing the value. The
> idea evidently is to simplify gbt_bpchar_consistent, but it's not
> acceptable if the opclass is supposed to support index-only scan.
>
> I see two ways to fix this:
>
> * Disallow index-only scan, by removing the fetch function for this
> opclass. This'd require a module version bump, so people wouldn't
> get that fix automatically.
>
> * Change gbt_bpchar_compress to not trim spaces (it becomes just
> like gbt_text_compress), and adapt gbt_bpchar_consistent to cope.
> This does nothing for the problem immediately, unless you REINDEX
> affected indexes --- but over time an index's entries would get
> replaced with untrimmed versions.
I think that the second way is preferable in the long run. It doesn't
need an explanation after years, why index-only scan is not supported
for that type. One-time mentioning the change and the need for REINDEX
in release notes seems more future-oriented to me.

Best regards,
Alexander

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-01-05 05:13:30 Re: pg_stat_statements and "IN" conditions
Previous Message Bharath Rupireddy 2022-01-05 04:54:25 Emit "checkpoint skipped because system is idle" message at LOG level if log_checkpoints is set