DOCS: skills + SQL cleanup

This commit is contained in:
jokob-sk committed 2026-09-10 10:59:33 +10:00
1 parent a976fe0923
commit cc3ccbcaf0
12 files changed
+195 -2

No files matched your search

+8
View File
@@ -575,6 +575,14 @@ def ensure_CurrentScan(sql) -> bool:
scanType STRING(250)
);
""")
# scanMac has no uniqueness constraint - multiple plugins commonly report
# the same MAC in one cycle (e.g. arp_scan + nslookup), so every lookup
# keyed on scanMac (update_presence_from_CurrentScan, insert_events, the
# LatestDeviceScan/LatestEventsPerMAC views) was a full table scan without
# this. Table is dropped every cycle, so the index is rebuilt with it -
# cheap insurance against O(n^2) scans at NOC-scale device counts (10k+ in
# real deployments).
sql.execute("CREATE INDEX IF NOT EXISTS idx_currentscan_scanmac ON CurrentScan(scanMac);")
return True
+3 -2
View File
@@ -164,9 +164,10 @@ CREATE TABLE CurrentScan (
scanVlan STRING(250),
scanParentMAC STRING(250),
scanParentPort STRING(250),
scanType STRING(250),
UNIQUE(scanMac)
scanFQDN STRING(250),
scanType STRING(250)
);
CREATE INDEX idx_currentscan_scanmac ON CurrentScan(scanMac);
CREATE TABLE IF NOT EXISTS AppEvents (
"index" INTEGER PRIMARY KEY AUTOINCREMENT,
guid TEXT UNIQUE,