perf(grid): pre-stringify JSON/JSONB values and truncate cell display

Serialize JSON/JSONB as strings in Postgres and MySQL drivers to avoid
repeated JSON.stringify in the render loop. Truncate cell display to
256 chars so the browser doesn't lay out huge text nodes on scroll.
This commit is contained in:
t8y2
2026-05-08 11:23:31 +08:00
parent fdf65ac5e3
commit 9fd16e3c1f
3 changed files with 8 additions and 6 deletions
+4 -2
View File
@@ -470,11 +470,13 @@ function toggleSort(colName: string) {
}
}
const CELL_DISPLAY_MAX_LENGTH = 256;
function formatCell(value: CellValue): string {
if (value === null) return "NULL";
if (typeof value === "boolean") return value ? "true" : "false";
if (typeof value === "object") return JSON.stringify(value);
return String(value);
const s = typeof value === "object" ? JSON.stringify(value) : String(value);
return s.length > CELL_DISPLAY_MAX_LENGTH ? s.slice(0, CELL_DISPLAY_MAX_LENGTH) : s;
}
function quoteIdent(name: string): string {