Skip to content

db.execute(custom_time_limit=...) can now exceed sql_time_limit_ms - #3106

Merged
simonw merged 3 commits into
mainfrom
claude/practical-galileo-da9wi4
Nov 22, 2026
Merged

simonw merged 3 commits into
mainfrom
claude/practical-galileo-da9wi4

Conversation

@simonw

@simonw simonw commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

db.execute(custom_time_limit=...) previously ignored any value higher than the sql_time_limit_ms setting, so internal code and plugins had no way to run a query with a longer limit. It now uses the value it is given, shorter or longer.

Claude Fable 5.2 Medium

Everything that relied on the old cap keeps it:

  • ?_timelimit= on the query and table views can still only shorten the limit.
  • facet_time_limit_ms and facet_suggest_time_limit_ms are still capped by sql_time_limit_ms.
  • So are the fixed limits used for table counts, homepage counts, autocomplete and foreign key suggestions.

These all go through a new datasette.capped_time_limit_ms(ms) helper, which returns min(ms, sql_time_limit_ms). Nothing in core passes a longer limit yet.

A timeout is still only treated as "expected" (not a span error) when the custom limit is shorter than the setting.

Things to note

  • capped_time_limit_ms() is not documented in internals.rst.
  • Facet gains time_limit_ms and suggest_time_limit_ms properties. Plugin Facet subclasses that pass self.ds.setting("facet_time_limit_ms") straight to execute() are no longer capped unless they switch to those properties.

Tests

  • custom_time_limit longer than the setting lets a slow query finish.
  • ?_timelimit=5000 stays capped on both views, and ?_timelimit=5 still shortens.
  • Facet, facet suggestion and table count limits are capped when sql_time_limit_ms is lower than them.
  • The telemetry test that asserted a larger custom_time_limit was ignored is replaced by one asserting it is applied.

Docs updated: internals.rst, json_api.rst, settings.rst and the changelog.


Generated by Claude Code

db.execute(custom_time_limit=) previously ignored any value higher than
the sql_time_limit_ms setting. Internal and plugin code can now use it to
run a query with a longer limit.

The ?_timelimit= query string argument is now capped in the table and
query views, so it can still only shorten the limit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Bvfq9gKFvZ3ohFmtddE8s
Facet, facet suggestion, table count, autocomplete and foreign key
suggestion queries pass their own shorter limits to db.execute(). Those
are capped at sql_time_limit_ms again, using a new
datasette.capped_time_limit_ms() helper shared with ?_timelimit=.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Bvfq9gKFvZ3ohFmtddE8s
@simonw simonw changed the title custom_time_limit can now exceed sql_time_limit_ms db.execute(custom_time_limit=...) can now exceed sql_time_limit_ms Nov 22, 2026
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (05d3f56) to head (c56f59c).

Files with missing lines Patch % Lines
datasette/facets.py 0.00% 6 Missing ⚠️
datasette/database.py 0.00% 3 Missing ⚠️
datasette/app.py 0.00% 2 Missing ⚠️
datasette/views/table.py 0.00% 2 Missing ⚠️
datasette/views/database.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3106   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         81      81           
  Lines      14577   14585    +8     
=====================================
- Misses     14577   14585    +8     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@simonw
simonw merged commit 56e02c1 into main Nov 22, 2026
16 checks passed
@simonw
simonw deleted the claude/practical-galileo-da9wi4 branch November 22, 2026 15:58
@simonw simonw added this to the Datasette 1.0 stable milestone Nov 22, 2026
simonw added a commit that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants