Skip to content

Optimise PostgresMetadataFetcher#283

Open
suddendust wants to merge 5 commits intohypertrace:mainfrom
suddendust:optimiseMetaFetcher
Open

Optimise PostgresMetadataFetcher#283
suddendust wants to merge 5 commits intohypertrace:mainfrom
suddendust:optimiseMetaFetcher

Conversation

@suddendust
Copy link
Copy Markdown
Contributor

@suddendust suddendust commented Mar 26, 2026

Description

I observed that querying information_schema for table metadata was much slower than querying pg_catalog for the same. See the following logs:

With information_schema:

2026-03-26 06:45:10.459 [pool-5-thread-3] INFO  o.h.c.d.p.PostgresLazyilyLoadedSchemaRegistry - {entityId=7a44307e-b93b-37a9-b53d-75fc07c713c3, entityType=API, requestId=b, shadowEventId=6bae0afe-6774-4cf5-b314-359ff396bb27, tenantId=3e761879-c77b-4d8f-a075-62ff28e8fa8c, writeType=CREATE_OR_REPLACE} Successfully loaded schema for table: entities_api_shadow, columns: 133, durationMs: 39

With pg_catalog:

2026-03-26 06:45:10.459 [pool-5-thread-3] INFO  o.h.c.d.p.PostgresLazyilyLoadedSchemaRegistry - {entityId=7a44307e-b93b-37a9-b53d-75fc07c713c3, entityType=API, requestId=b, shadowEventId=6bae0afe-6774-4cf5-b314-359ff396bb27, tenantId=3e761879-c77b-4d8f-a075-62ff28e8fa8c, writeType=CREATE_OR_REPLACE} Successfully loaded schema for table: entities_api_shadow, columns: 133, durationMs: 39

This is ~ 26x faster.

Testing

Tested both version in an sandbox env.

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

Documentation

https://dba.stackexchange.com/questions/302587/what-is-faster-pg-catalog-or-information-schema

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.20%. Comparing base (f3bc54c) to head (b900749).

❗ There is a different number of reports uploaded between BASE (f3bc54c) and HEAD (b900749). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (f3bc54c) HEAD (b900749)
integration 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               main     #283       +/-   ##
=============================================
- Coverage     81.25%   55.20%   -26.06%     
+ Complexity     1486     1485        -1     
=============================================
  Files           240      240               
  Lines          7176     7168        -8     
  Branches        676      675        -1     
=============================================
- Hits           5831     3957     -1874     
- Misses          916     2838     +1922     
+ Partials        429      373       -56     
Flag Coverage Δ
integration ?
unit 55.20% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant