(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
This commit is contained in:
Alex Hall 2022-03-08 11:54:25 +02:00
parent 222dc505eb
commit 77a5d31afe

View File

@ -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