Skip to content

PAX: treat PAX tables as AO-like in index path generation - #1761

Merged
yjhjstz merged 4 commits into
apache:mainfrom
yjhjstz:pax/treat-as-ao-for-index-paths
Jul 30, 2026
Merged

PAX: treat PAX tables as AO-like in index path generation#1761
yjhjstz merged 4 commits into
apache:mainfrom
yjhjstz:pax/treat-as-ao-for-index-paths

Conversation

@yjhjstz

@yjhjstz yjhjstz commented May 21, 2026

Copy link
Copy Markdown
Member

Random TID fetches on PAX tables re-decompress entire stripes (1.5 MB ZSTD blocks) per tuple and bypass the buffer pool, just like AO/AOCS. get_index_paths() already routes AO/AOCS relations to Bitmap paths only and skips IndexScan/IndexOnlyScan (the latter is unimplemented for AO). Extend the same treatment to PAX so that a btree index over a PAX table no longer triggers full-table Index Only Scan when enable_seqscan=off, which previously caused customer queries to hang indefinitely.

Detection uses the existing PAX_AM_OID; RelOptInfo gains a relam field cached from rd_rel->relam (mirroring amhandler) so the planner can do the comparison without opening the relation.

Heap tables and existing AO behavior are unaffected.

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


@gfphoenix78

Copy link
Copy Markdown
Contributor

LGTM, please fix the test failures.

@my-ship-it my-ship-it left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your judgment on the core direction — routing PAX through Bitmap is reasonable.

Some minor suggestion:

  • Replace the relam field with reuse of the amhandler path;
  • Does PAX also want the gp_enable_ao_indexscan path?

Comment thread src/backend/optimizer/path/indxpath.c Outdated
@yjhjstz
yjhjstz force-pushed the pax/treat-as-ao-for-index-paths branch from 32ae28d to ad5d994 Compare May 25, 2026 15:42
@yjhjstz
yjhjstz requested a review from gfphoenix78 May 25, 2026 15:42
@yjhjstz
yjhjstz force-pushed the pax/treat-as-ao-for-index-paths branch 5 times, most recently from 24eeb2e to f1e4054 Compare May 25, 2026 20:29

@my-ship-it my-ship-it left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,thanks

@yjhjstz
yjhjstz force-pushed the pax/treat-as-ao-for-index-paths branch from f1e4054 to 034f9ff Compare July 29, 2026 08:27
With PAX relations now treated as AO-like in get_index_paths() (see
preceding commit), a btree index over a PAX table no longer produces
Index Scan / Index Only Scan plans -- only Bitmap Heap/Index Scan (or
Seq Scan) paths survive. Regenerate the affected PAX regression
expected outputs to match.

Validated by running the PAX regress suite (parallel_schedule +
greenplum_schedule) with default_table_access_method=pax; the refreshed
files reflect the actual planner output.
@yjhjstz
yjhjstz force-pushed the pax/treat-as-ao-for-index-paths branch from 034f9ff to 496bd3b Compare July 29, 2026 08:35
yjhjstz added 2 commits July 29, 2026 18:27
… index routing

Refresh the *_optimizer.out expected files to match GPORCA plans under
default_table_access_method=pax with optimizer=on, where PAX index paths
now surface as Bitmap/Seq scans instead of Index/Index Only Scan.

Add index_including_optimizer.out: nametbl is a PAX table, so the Postgres
planner (optimizer=off) emits a Bitmap plan (base index_including.out) while
GPORCA (optimizer=on) still emits an Index Only Scan over the covering index.
The two optimizers diverge, so opt=on needs its own expected file.

Refreshed: aggregates, bfv_joins, create_index, incremental_sort, inherit,
join, misc_functions, partition_prune, partition_pruning, privileges,
rowtypes, select, subselect_gp, union (_optimizer.out).
@yjhjstz
yjhjstz force-pushed the pax/treat-as-ao-for-index-paths branch 2 times, most recently from 08b54ed to fe113e6 Compare July 29, 2026 13:09
The nametbl covering-index test only did VACUUM FREEZE with no ANALYZE, so
with no column statistics GPORCA used default cardinalities and the plan
flipped between Index Only Scan and Index Scan across environments. Add
ANALYZE nametbl so the intended Index Only Scan plan is deterministic under
both optimizer=off and optimizer=on.

@gfphoenix78 gfphoenix78 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@yjhjstz
yjhjstz merged commit d482b42 into apache:main Jul 30, 2026
248 of 254 checks passed
@yjhjstz
yjhjstz deleted the pax/treat-as-ao-for-index-paths branch July 30, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants