Skip to content

2.25.2.0-b153

tagged this 13 Mar 04:37
Summary:
This change disables index-only scans on copartitioned indexes. Before this change, it was expected that an AM with a [[https://github.com/yugabyte/yugabyte-db/blob/de6a7ba096bbd000c6456133d5fb8e637f1bb753/src/postgres/src/include/access/amapi.h#L324|canreturn]] function that just returns false like [[https://github.com/yugabyte/yugabyte-db/blob/de6a7ba096bbd000c6456133d5fb8e637f1bb753/src/postgres/third-party-extensions/pgvector/src/ybvector/ybvectorutil.c#L85|this one]] would never serve an index-only scan.

However, it turns out that such AMs can still serve index-only scans when there are no target columns, such as when the target is `COUNT(*)`. More specifically, `check_index_only` returns true [[https://github.com/yugabyte/yugabyte-db/blob/de6a7ba096bbd000c6456133d5fb8e637f1bb753/src/postgres/src/backend/optimizer/path/indxpath.c#L2454|here]] as the linked check effectively reduces to `bms_is_subset(NULL, NULL)`.

This behavior is problematic for copartitioned indexes, which are not intended to support index-only scans. To address this, the change modifies check_index_only to return false when dealing with copartitioned indexes. Additionally, this change caches an index AM’s `yb_amiscopartitioned` value in IndexOptInfo, similar to how `yb_amhasgetbitmap` is handled.

Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgvector'

Reviewers: jason

Reviewed By: jason

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D42462
Assets 2
Loading