evolve_forever: лучший-за-всё-время через частичный индекс, а не max()-скан

MAX(efficiency) сканировал всю базу (6.7ГБ) на старте каждого цикла —
минуты мёртвого времени, растущие с базой.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jze9
2026-07-09 11:54:19 +05:00
parent e52026d2b2
commit 005ffaf04b

View File

@@ -12,7 +12,9 @@ while true; do
import sqlite3 import sqlite3
try: try:
c = sqlite3.connect("results/gausse.sqlite3") c = sqlite3.connect("results/gausse.sqlite3")
row = c.execute("select max(efficiency) from runs where feasible=1").fetchone() # НЕ max(): он сканирует всю базу (гигабайты); частичный индекс отдаёт мгновенно
row = c.execute("select efficiency from runs indexed by idx_runs_feas_eff "
"where feasible=1 order by efficiency desc limit 1").fetchone()
print(f"{row[0]*100:.2f}%" if row and row[0] is not None else "пока нет") print(f"{row[0]*100:.2f}%" if row and row[0] is not None else "пока нет")
except Exception: except Exception:
print("пока нет") print("пока нет")