Skip to content

Performance: Redundant catalog read in pending_sync_rows() which increases fetch time #21

Description

@aditya3799

Background

In a previous optimization (PR #19), a redundant call to selected_or_default_graph_id_via_definer() was successfully removed from current_catalog_state(). This helped reduce the ~3.5ms unamortized fixed cost of graph traversals.

The Problem

However, looking closely at ensure_current_graph(), the very next line calls pending_sync_rows(applied_sync_id).

Tracing this call shows that it eventually hits SyncReplayContext::load(), which triggers a full read_catalog(). This means ensure_current_graph() is still doing a full redundant catalog read (including two massive SPI queries for _registered_tables and _registered_edges), completely undermining the optimization from PR #19.

Proposed Solution

Since ensure_current_graph() already loads catalog_state right before calling pending_sync_rows(), we can extract the applicable_table_oids from the loaded state and pass them directly to pending_sync_rows. This bypasses SyncReplayContext::load() entirely and eliminates the remaining redundant SPI queries from the hot path.

I will submit a PR with this fix shortly!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions