Skip to content

perf(database): zero-allocation hex formatting for BLOB/Bytea and eliminate split in date cell rendering #1529

Open

Description

@ZhuchkaTriplesix

Problem

In postgres_result_cells.dart (lib/core/database/postgres_result_cells.dart):

  1. postgresByteaHexDisplay loops over Uint8List and calls b.toRadixString(16).padLeft(2, '0') for each byte. For a 2KB binary blob, this creates 4,096 temporary strings.
  2. In date-only cells, value.toIso8601String().split('T').first allocates a 2-element list and discards the second element on every date cell of every row (e.g. 50,000 lists for 50,000 rows).

Solution

  • Use a static hex character lookup table (const _hexDigits = '0123456789abcdef') and write char codes directly without intermediate toRadixString or padLeft allocations.
  • Extract the date substring (iso.substring(0, 10)) or format directly without split('T').

Benefits

  • 0 intermediate string allocations per byte in binary cell rendering.
  • 0 List allocations when displaying date columns in query results.

Activity

  1. added this to the 0.5.0 milestone on Oct 12, 2026
  2. added
    backendBackend database driver execution and queries
    coreCore library logic and services
    P2Medium priority / Parity & Refactoring
    on Oct 12, 2026
  3. added a commit that references this issue on Oct 15, 2026
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 queriescoreCore library logic and servicesenhancementNew feature or requestperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions