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

Cache table AM in Chunk struct #7284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erimatnor
Copy link
Contributor

@erimatnor erimatnor commented Sep 19, 2024

A chunk can use different table access methods so to support this more easily, cache the AM oid in the chunk struct. This allows identifying the access method quickly at, e.g., planning time.

Disable-check: force-changelog-file

A chunk can use different table access methods so to support this more
easily, cache the AM oid in the chunk struct. This allows identifying
the access method quickly at, e.g., planning time.
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.30%. Comparing base (59f50f2) to head (8f47bc2).
Report is 348 commits behind head on main.

Files with missing lines Patch % Lines
src/utils.c 87.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7284       +/-   ##
===========================================
+ Coverage   80.06%   92.30%   +12.23%     
===========================================
  Files         190      205       +15     
  Lines       37181    38442     +1261     
  Branches     9450     9964      +514     
===========================================
+ Hits        29770    35484     +5714     
+ Misses       2997     2954       -43     
+ Partials     4414        4     -4410     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1620,6 +1620,7 @@ chunk_tuple_found(TupleInfo *ti, void *arg)
chunk->hypertable_relid = ts_hypertable_id_to_relid(chunk->fd.hypertable_id, false);

chunk->relkind = get_rel_relkind(chunk->table_id);
chunk->amoid = ts_get_rel_am(chunk->table_id);
Copy link
Member

Choose a reason for hiding this comment

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

Some observations on this:

  1. I think you should add this to ts_chunk_scan_by_chunk_ids as well. Probably a good idea to do a catalog lookup once, because the relkind and amoid are in the same pg_class catalog. Maybe you can make a function and use it here and there as well.

  2. It's not failing, so this means it's dead code now. Let's add some assertion that this is not null to improve test coverage.

@akuzm
Copy link
Member

akuzm commented Sep 19, 2024

I think we can merge much more parts of the TAM planning in this PR in the following way:

  1. Port the check for hyperstore Oid as is, just make it get_am_oid("hyperstore", /* missing_ok = */ true), so that it works even w/o the TAM
  2. Would be good to cache the TAM oid the same way as extension oid.
  3. Port the ts_relation_uses_hyperstore(Oid relid) as is. The cached TAM oid will be InvalidOid until we implement the acutal TAM, so the function will return false.
  4. Port the code that uses this function where it makes sense. I think it's OK if some of it becomes dead code, because we'll be testing it in the TAM PR anyway.

This way we can actually test the place where I saw the regression in this PR, which was my original motivation to suggest splitting it. And also remove much more changes from the TAM PR. What do you think?

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.

2 participants