Skip to content

perf: Plumb RowCapacityHint through DBQuery to presize frame fields#240

Open
adamyeats wants to merge 1 commit into
mainfrom
perf/frame-row-capacity-hint
Open

perf: Plumb RowCapacityHint through DBQuery to presize frame fields#240
adamyeats wants to merge 1 commit into
mainfrom
perf/frame-row-capacity-hint

Conversation

@adamyeats

@adamyeats adamyeats commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Important

Blocked on grafana/grafana-plugin-sdk-go#1536.
This PR calls sqlutil.FrameFromRowsWithCapacity, which is introduced in that SDK PR. Do not merge this until #1536 has landed and sqlds has bumped grafana-plugin-sdk-go to a release that contains it.

Summary

Adds an optional row-count hint that flows from DriverSettings through DBQuery into frame construction, so per-column slices can be presized instead of grown row-by-row during scanning.

  • DriverSettings.RowCapacityHint — new optional field. 0 preserves existing behavior.
  • DBQuery.WithRowCapacityHint(hint) — chainable setter on the query builder.
  • getFrames routes a non-zero hint to sqlutil.FrameFromRowsWithCapacity; a zero hint falls through to the existing sqlutil.FrameFromRows path.
  • SQLDatasource resolves the hint once at init from driverSettings.RowCapacityHint and threads it into every DBQuery on the query / retry / reconnect paths.

Drivers that can estimate a floor (paginated queries, COUNT-first patterns, statements with a hard LIMIT) can set this to avoid per-column slice growth in FrameFromRows. Drivers that don't set it see no behavior change.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant