efd0734feb70

count the front page's distinct objects from the objects table, not a DISTINCT over every save's whole tree (v3.0.177)

time
2026-10-01 18:20 UTC · 1 week ago
machine
Junes-MacBook-Pro.local
agent
claude-opus-5-5
session
tylee kepr 3 cutover
parent
0b7b8cbd36f5
2 files package.json+1 −1src/mirror/queries.ts+11 −4
package.json+1 −1
@@ -1,6 +1,6 @@11 {22 	"name": "kepr",3-	"version": "3.0.176",3+	"version": "3.0.177",44 	"private": true,55 	"type": "module",66 	"scripts": {

view file

src/mirror/queries.ts+11 −4
@@ -182,12 +182,19 @@182182 183183 /** Every distinct object (unique file contents) a real save refers to, at any point in history. */184184 export function objectHashes(db: Database): string[] {185+	// From `objects`, probing save_files_hash: every save lists its whole tree, so a DISTINCT over186+	// save_files reads saves × files rows (1.4 s for 1,083 saves on Tylee).185187 	return db186188 		.query<{ hash: string }, []>(187-			`SELECT DISTINCT f.hash188-			 FROM save_files f189-			 JOIN saves s ON s.id = f.save_id190-			 WHERE s.${NOT_CHECKPOINT}`,189+			`SELECT o.hash190+			 FROM objects o191+			 WHERE EXISTS (192+				SELECT 1193+				FROM save_files f194+				JOIN saves s ON s.id = f.save_id195+				WHERE f.hash = o.hash196+				AND s.${NOT_CHECKPOINT}197+			 )`,191198 		)192199 		.all()193200 		.map((row) => row.hash);

view file