[PERF] Pre-aggregated per-minute counts (log_counts rollup) for stats, histograms and facets
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- mysql, php
- Ambito
- backend, databases, performance
Direzione di ricerca
Start by locating AsyncMysqlBatchWriter, the database migrations, the retention code, and the API routing and OpenAPI files. Then trace how entries are inserted and pruned, and how existing CLI commands and tests are structured. Done means implementing the rollup migration, transactional batch updates, backfill command, histogram endpoint and spec, and documented retention behavior, with tests confirming counts against seeded log_entries.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Maintain a small rollup table of counts per minute, app and level, updated as entries are written. Histograms, facet counts and approximate totals can then be read from it instead of scanning log_entries.
Motivation
#56 (metrics/statistics endpoint) and guibranco/logstream-ui#159 (dashboard/overview screen) both need counts over time. With COUNT(*) … GROUP BY on the raw table, the cost grows with the amount of data stored. A rollup table makes these queries tiny, and lets the stats drawer show real totals instead of counting only the entries loaded in the browser.
Implementation
CREATE TABLE IF NOT EXISTS log_counts (
bucket DATETIME NOT NULL, -- minute, UTC
app_key VARCHAR(100) NOT NULL,
app_id VARCHAR(100) NOT NULL,
level ENUM('debug','info','notice','warning','error','critical') NOT NULL,
n INT UNSIGNED NOT NULL,
PRIMARY KEY (bucket, app_key, app_id, level)
) ENGINE=InnoDB;
- In
AsyncMysqlBatchWriter, group each batch by key in PHP and run one multi-rowINSERT … ON DUPLICATE KEY UPDATE n = n + VALUES(n), so there is no extra query per entry. - Retention: when rows are pruned, either decrement the counts or keep rollups for longer (they are tiny) and document that they count everything ever ingested. Pick one approach and document it.
- Backfill: a one-off CLI command that builds
log_countsfrom existing rows. GET /api/stats/histogram?interval=1m|5m|1h&app_key=…&level=…&range=24hreads from the rollup (larger intervals useGROUP BYon the bucket).
Acceptance criteria
- Migration creates
log_counts - Batch writer updates counts in the same transaction as the insert
- Backfill command
- Histogram endpoint plus OpenAPI spec
- Retention behaviour decided and documented
- Tests: counts match
COUNT(*)on seeded data
Generated by Claude Code
- Lingua principale
- PHP
- Stelle
- 1
- Fork
- 0
- Merge medio
- 1h 58m
- PR unite (30g)
- 53
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di guibranco/logstream-server
-
🎲 database 🕒 low effort 🚀 performance enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
guibranco/logstream-server#153 ·
I maintainer di solito rispondono entro 1 giorno
-
✨ feature 🎲 database 🕓 medium effort enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
guibranco/logstream-server#162 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
⚙️ CI/CD 👷🏼 infrastructure 🕓 medium effort enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
guibranco/logstream-server#160 ·
I maintainer di solito rispondono entro 1 giorno
-
🎲 database 🕒 low effort 🛠️ automation enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
guibranco/logstream-server#159 ·
I maintainer di solito rispondono entro 1 giorno
-
✨ feature 🎲 database 🕓 medium effort enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
guibranco/logstream-server#158 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di guibranco/logstream-server
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
vimeo/psalm#14139 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
sync-en
Difficoltà 1/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
wpvc
Difficoltà 1/5 1-3 ore Idoneità per principianti 67/100
10up/simple-local-avatars#386 ·
-
not confirmed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Bug (unconfirmed) Documentation :books:
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
FreshRSS/FreshRSS#9577 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno