fix: enable SQLite WAL mode and add consistent LIMIT to KG timeline
- Enable WAL journal mode in _conn() for better concurrent read performance and reduced SQLITE_BUSY risk - Add LIMIT 100 to entity-filtered timeline query (was unbounded, while global timeline already had LIMIT 100) Findings: #8 (HIGH — no WAL mode), #22 (LOW — inconsistent limits) Includes test infrastructure from PR #131. 92 tests pass.
This commit is contained in:
@@ -87,7 +87,9 @@ class KnowledgeGraph:
|
||||
conn.close()
|
||||
|
||||
def _conn(self):
|
||||
return sqlite3.connect(self.db_path, timeout=10)
|
||||
conn = sqlite3.connect(self.db_path, timeout=10)
|
||||
conn.execute("PRAGMA journal_mode=WAL")
|
||||
return conn
|
||||
|
||||
def _entity_id(self, name: str) -> str:
|
||||
return name.lower().replace(" ", "_").replace("'", "")
|
||||
@@ -284,6 +286,7 @@ class KnowledgeGraph:
|
||||
JOIN entities o ON t.object = o.id
|
||||
WHERE (t.subject = ? OR t.object = ?)
|
||||
ORDER BY t.valid_from ASC NULLS LAST
|
||||
LIMIT 100
|
||||
""",
|
||||
(eid, eid),
|
||||
).fetchall()
|
||||
|
||||
Reference in New Issue
Block a user