Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick series of AO options/AO relations related commits. #871

Merged
merged 4 commits into from
Jan 21, 2025

Conversation

reshke
Copy link
Contributor

@reshke reshke commented Jan 14, 2025

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


@reshke reshke changed the title Support setting table-level reloptions for AO/AOCO tables Cherry-pick series of AO options/AO relations related commits. Jan 14, 2025
@reshke reshke added the cherry-pick cherry-pick upstream commts label Jan 14, 2025
@reshke reshke force-pushed the at_set_am2 branch 3 times, most recently from 3e0d4db to 1cbd57e Compare January 15, 2025 07:10
soumyadeep2007 and others added 3 commits January 16, 2025 05:41
This allows a user to modify table-level AO reloptions such as
compresslevel on an existing AO/AOCO table with:
ALTER TABLE <> SET([reloptions]);

Example:

CREATE TABLE aorelopts USING ao_row
	AS SELECT * FROM generate_series(1, 1000);
ALTER TABLE aorelopts SET (compresslevel=7, checksum=false);

We rewrite the table as AO reloption changes imply on-disk changes. (We
only rewrite the table if the options have really changed)

Note: we got rid of the "fillfactor" reloption for AO tables as it was
never really implemented. Also removed the "appendonly" reloption macro
(SOPT_APPENDONLY) that's no longer used after we supported table AM for
AO/AOCO tables.

Co-authored-by: Huansong Fu <[email protected]>
Example workflow of changing access method from a
Heap table (Oid:a) to an AO table:
- Create transient AO table (Oid:b) and its AO aux tables in
  make_new_heap
- Copy table data into the transient table
- Swap Oids in the pg_appendonly entry so that newly generated
  aux tables are mapped to Oid a in ATAOEntries
- Swap attributes in pg_class entry between the two tables
  (such as relfilenode, relam, ...)
- Now dropping the transient table will use the heap AM and
  delete the original heap relation file.
This allow users to specify reloptions when they are switching the
storage model of the table:

ALTER TABLE <> SET ACCESS METHOD <> WITH ([reloptions]);

We also support the legacy `appendonly`/`appendoptimized` options
in the SET WITH clause:

ALTER TABLE <> SET WITH (appendonly|appendoptimized=true|false, [reloptions]);

Examples:
CREATE TABLE tab (a int);
ALTER TABLE tab SET ACCESS METHOD ao_row WITH (blocksize=65536);

or:
ALTER TABLE tab SET WITH (appendonly=true, blocksize=65536);

Note that if a user specifies different access methods in a single
statement, an error will be thrown. E.g.:

ALTER TABLE ataoset SET ACCESS METHOD ao_row WITH(appendonly=true, orientation=column);
ERROR:  ACCESS METHOD is specified as "ao_row" but the WITH option indicates it to be "ao_column"
LINE 1: ALTER TABLE ataoset SET ACCESS METHOD ao_row WITH(appendonly...
                                                     ^

Also, normally access method change requires table rewrite. But
if a user uses the above syntax but specify the same access method
and/or reloptions, we will not do a table rewrite.

Also adjusted the test output of alter_distribution_policy that
the altered reloptions should be shown.
my-ship-it
my-ship-it previously approved these changes Jan 16, 2025
@reshke
Copy link
Contributor Author

reshke commented Jan 18, 2025

Cherry-picked only 3 commit in this branch, as following commits tends to be really problematic, and i need these for #859

@reshke reshke requested a review from my-ship-it January 20, 2025 09:17
@reshke reshke merged commit ed022d3 into main Jan 21, 2025
59 of 60 checks passed
@reshke reshke deleted the at_set_am2 branch January 21, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick cherry-pick upstream commts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants