perf: avoid uncessary duckdb calls in stats and getting db names#8250
Merged
perf: avoid uncessary duckdb calls in stats and getting db names#8250
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves DuckDB-related performance by eliminating redundant catalog/stat queries when generating column previews and listing databases, while adding tests to lock in the new behavior.
Changes:
- Reuse
stats.totalinget_column_preview_for_duckdbto avoid an extraCOUNT(*)query. - Add a
backfill_empty_databasesswitch to skipduckdb_databases()calls in theduckdb_columns()(agg-query) fallback path. - Update/add tests to cover
stats.total is Noneand backfill behavior, and standardize DuckDB tests on@pytest.mark.requires("duckdb")intest_get_datasets.py.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
marimo/_data/preview_column.py |
Removes redundant row-count query and threads a ChartBuilder into chart-spec generation. |
marimo/_data/get_datasets.py |
Adds backfill_empty_databases flag to avoid extra duckdb_databases() calls in the agg-query path; hoists constants. |
tests/_data/test_preview_column.py |
Adds coverage for stats.total=None to ensure no crash/no chart generation. |
tests/_data/test_get_datasets.py |
Converts DuckDB skips to @pytest.mark.requires("duckdb") and adds tests verifying backfill behavior and avoiding _get_duckdb_database_names calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| def has_updates_to_datasource(query: str) -> bool: | ||
| import duckdb |
There was a problem hiding this comment.
This import of module duckdb is redundant, as it was previously imported on line 21.
This import of module marimo._sql.engines.duckdb is redundant, as it was previously imported on line 21.
Light2Dark
approved these changes
Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
COUNT(*)query in get_column_preview_for_duckdb — reuse stats.total_get_duckdb_database_namesquery in the duckdb_columns() fallback path. avoids an extra SELECT * FROM duckdb_databases() query