Skip to content

perf(grid): eliminate duplicate 40-row sampling in computeResultGridColumnWidths and distributeResultGridSpareWidth #1349

Closed

Description

@ZhuchkaTriplesix

Summary

In lib/features/workspace/grid/grid_column_sizer.dart:

  1. computeResultGridColumnWidths scans up to kSampleRows = 40 rows across all columns to calculate character length bounds (maxRowChars) and column widths.
  2. Immediately afterwards, if distributeSpareWidth is true and remaining spare width is available, distributeResultGridSpareWidth iterates over the exact same 40 rows again to recompute maxRowChars for each column from scratch.

For tables with many columns (e.g. 50–100+ columns), this executes a redundant second pass over the sample rows and repeats string length inspections during initial layout of new query results (#982).

Proposed Solution

  1. Cache or return the computed maxRowChars directly from computeResultGridColumnWidths.
  2. Pass the precomputed sample character lengths into distributeResultGridSpareWidth to avoid re-iterating over the sample rows.

Acceptance Criteria

  • distributeResultGridSpareWidth reuses the character counts calculated during computeResultGridColumnWidths.
  • No duplicate row sampling passes during column width calculation.
  • Calculated column widths remain identical.

Activity

  1. added
    frontendTheme parser epic label: frontend
    performanceTheme parser epic label: performance
    data-gridInteractive data grid, cell editor, filtering, groupings
    P3Low priority / Polish & Enhancements
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1411 (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

    P3Low priority / Polish & Enhancementsdata-gridInteractive data grid, cell editor, filtering, groupingsfrontendTheme parser epic label: frontendperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions