Skip to content

perf(sqlite): eliminate redundant double string conversion pass in SqliteSqlExecutionDelegate #1354

Closed

Description

@ZhuchkaTriplesix

Summary

In lib/features/sqlite/sqlite_sql_workspace.dart (lines 108–114):

final rawRows = results.take(limitCount).map((row) {
  return cols
      .map((col) => sqliteResultCellToDisplayString(row[col]))
      .toList();
}).toList();

final outRows = await convertResultRowsToStringsAdaptive(rawRows);
  1. rawRows is already converted into a List<List<String>> using sqliteResultCellToDisplayString.
  2. Immediately on line 114, rawRows is passed into convertResultRowsToStringsAdaptive(rawRows).

As explicitly documented in postgres_result_utils.dart (lines 39–42):

"Rows are already strings after this, so callers must not run them through convertResultRowsToStringsAdaptive again: that would walk (and, from 1000 rows, copy to an isolate) the whole matrix a second time without being able to recover any type information."

For SQLite queries returning $\ge 1000$ rows, convertResultRowsToStringsAdaptive copies the entire 2D string matrix to a worker isolate and back, allocating a duplicate matrix of identical strings and doubling the execution CPU cost.

Proposed Solution

  1. Pass raw objects directly to convertResultRowsToStringsAdaptive with a single-pass conversion, or:
  2. Use rawRows directly without calling convertResultRowsToStringsAdaptive a second time (or intern strings during the first pass).

Acceptance Criteria

  • SQLite query execution performs only a single pass over result rows.
  • Eliminates isolate serialization/deserialization overhead for SQLite result sets $\ge 1000$ rows.
  • Displayed grid cells and cell editing remain identical.

Activity

  1. added
    performanceTheme parser epic label: performance
    sqliteSQLite database driver and workspace
    backendBackend database driver execution and queries
    P2Medium priority / Parity & Refactoring
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1407 (merged into dev).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringbackendBackend database driver execution and queriesperformanceTheme parser epic label: performancesqliteSQLite database driver and workspace

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions