Skip to content

perf(sql): clamp oversized LIMIT / FETCH for result caps (#416) - #430

Merged
ZhuchkaTriplesix merged 1 commit into
issue/415-sqlite-inject-limitfrom
issue/416-postgres-clamp-limit
Jul 27, 2026
Merged

perf(sql): clamp oversized LIMIT / FETCH for result caps (#416)#430
ZhuchkaTriplesix merged 1 commit into
issue/415-sqlite-inject-limitfrom
issue/416-postgres-clamp-limit

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

  • injectSqlLimit now clamps author LIMIT / LIMIT ALL / FETCH FIRST n ROWS ONLY when above the Preferences row cap
  • Postgres SQL workspace already calls injectSqlLimit — oversized LIMIT 999999 no longer loads a full Result of that size
  • Docs + unit tests updated

Depends on / stacks on #429 (#415). After #429 merges to dev, retarget this PR to dev (or merge stack).

Closes #416
Parent: #414

Notes

True portal/ResultStream row-take without buffering is deferred — the postgres package’s execute() still materializes a Result; clamping keeps that buffer ≤ cap for typical SELECT.

Test plan

  • flutter test test/core/database/sql_limit_test.dart test/core/database/postgres_sql_test.dart
  • Manual Postgres: SELECT * FROM big LIMIT 1000000 with cap 5000 → capped status, no huge memory spike
  • Manual: LIMIT 10 unchanged; LIMIT ALL → capped

Extend injectSqlLimit to clamp LIMIT n, LIMIT ALL, and FETCH FIRST
when larger than the UI row cap so Postgres (and SQLite) engines do
not buffer more rows than Preferences allow. Document the policy.

Closes #416
@github-actions github-actions Bot added performance Theme parser epic label: performance core Core library logic and services labels Jul 27, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit b8b1752 into issue/415-sqlite-inject-limit Jul 27, 2026
1 check passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the issue/416-postgres-clamp-limit branch July 27, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core library logic and services performance Theme parser epic label: performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant