Skip to content

Conversation

@rautenrieth-da
Copy link
Contributor

We have a partial index

create index updt_hist_tran_hi_mi_ui_import_updates
    on update_history_transactions (history_id, migration_id, update_id)
    where record_time = -62135596800000000

so it should be fast to fetch all import updates, but that still leads to sequential scans over all creates (because the planner thinks we have thousands of create events per update on average).

New query plan is

Aggregate (cost=19246.47..19246.48 rows=1 width=32) (actual time=72.576..72.578 rows=1 loops=1)
--
-> Index Scan using updt_hist_crea_hi_mi_rt on update_history_creates c (cost=0.57..19220.99 rows=10191 width=142) (actual time=35.798..63.413 rows=14464 loops=1)
Index Cond: ((history_id = 1) AND (migration_id = 2) AND (record_time = '-62135596800000000'::bigint))
Planning Time: 12.030 ms
Execution Time: 72.734 ms

[ci]

Signed-off-by: Robert Autenrieth <robert.autenrieth@digitalasset.com>
@rautenrieth-da rautenrieth-da force-pushed the rautenrieth-da/faster-getLastImportUpdateId branch from 0199fcb to c389696 Compare June 11, 2025 00:53
Copy link
Contributor

@OriolMunoz-da OriolMunoz-da left a comment

Choose a reason for hiding this comment

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

thanks! that denormalization paying dividends 🤪

@rautenrieth-da rautenrieth-da merged commit 991c59f into main Jun 11, 2025
60 checks passed
@rautenrieth-da rautenrieth-da deleted the rautenrieth-da/faster-getLastImportUpdateId branch June 11, 2025 12:17
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