From 77a5d31afe49154a5205dd8a01e59f6ac52f45af Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Tue, 8 Mar 2022 11:54:25 +0200 Subject: [PATCH] (core) More accurate data size measurement Summary: As suggested by @dsagal in https://phab.getgrist.com/D3277#inline-36801, change to query `SUM(pgsize - unused)` instead of `SUM(pgsize)` to measure actual data size more accurately. Technically this doesn't reflect the database file size as accurately, but it should reflect sandbox memory usage better, and more importantly it should allow users to see data size decreasing when they delete stuff. Test Plan: Tested manually by adding rows to a doc and looking at the logs. The data size is smaller and changes more granularly. Reviewers: dsagal, paulfitz Reviewed By: paulfitz Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3313 --- app/server/lib/DocStorage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/server/lib/DocStorage.ts b/app/server/lib/DocStorage.ts index 8bbddb0b..6e569099 100644 --- a/app/server/lib/DocStorage.ts +++ b/app/server/lib/DocStorage.ts @@ -1556,7 +1556,7 @@ export class DocStorage implements ISQLiteDB, OnDemandStorage { this._lastLoggedDataSize = now; const result = await this.get(` - SELECT SUM(pgsize) AS totalSize + SELECT SUM(pgsize - unused) AS totalSize FROM dbstat WHERE NOT ( name LIKE 'sqlite_%' OR