Skip to content

Fix: Reduce parsing overhead and improve performance when unpausing snapshots deployed to prod#3627

Merged
izeigerman merged 1 commit intomainfrom
fix-improve-performance-of-unpause-snapshots
Jan 14, 2025
Merged

Fix: Reduce parsing overhead and improve performance when unpausing snapshots deployed to prod#3627
izeigerman merged 1 commit intomainfrom
fix-improve-performance-of-unpause-snapshots

Conversation

@izeigerman
Copy link
Contributor

Unpausing snapshots that are deployed to prod involves fetching all snapshots that share the same version as the ones being deployed.

Before this change, fetching snapshots with the same versions involved full parsing of snapshot objects, including their models and queries. This caused a significant performance issue for projects with a high number of models, especially forward-only models.

With this update, SQLMesh will perform only a partial parsing when fetching snapshots with the same version, falling back to parsing the full snapshot only when absolutely necessary (which should be rare).

Additionally, this should also improve the performance of deleting expired snapshots, which relies on the same method to fetch snapshots with the same version.

@izeigerman izeigerman requested a review from a team January 14, 2025 01:04
@izeigerman izeigerman force-pushed the fix-improve-performance-of-unpause-snapshots branch from d9f682f to 499e2c3 Compare January 14, 2025 01:27
@izeigerman izeigerman force-pushed the fix-improve-performance-of-unpause-snapshots branch from 499e2c3 to d6f6cfa Compare January 14, 2025 01:41
return self.change_category == SnapshotChangeCategory.FORWARD_ONLY

@property
def normalized_effective_from_ts(self) -> t.Optional[int]:
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make a mixin for these shared methods or no, not worth it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the only one. Didn't want to bother for now, but I'm open to reconsider

snapshot.snapshot_id,
target_snapshot.snapshot_id,
)
full_snapshot = snapshot.full_snapshot
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think it's worth hitting the cache here, or allowing full_snapshot to take in a cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe as a follow-up. It should happen rarely enough to not matter.

@izeigerman izeigerman merged commit 295d37a into main Jan 14, 2025
3 checks passed
@izeigerman izeigerman deleted the fix-improve-performance-of-unpause-snapshots branch January 14, 2025 18:27
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