From a24eed2d9f415f4130f4b10122d473569f59ef55 Mon Sep 17 00:00:00 2001 From: Nima Boubanian <60567012+nimaboubanian@users.noreply.github.com> Date: Sun, 19 Apr 2026 01:10:04 +0200 Subject: [PATCH] fix: correct VES ratio in iterated_execution The denominator was mistakenly using gold_sql for both operands, making the ratio always 1.0. Changed to predicted_sql so the efficiency score actually reflects how fast the predicted query runs relative to the gold standard. --- premsql/executors/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/premsql/executors/base.py b/premsql/executors/base.py index 2321027..9e91131 100644 --- a/premsql/executors/base.py +++ b/premsql/executors/base.py @@ -46,10 +46,13 @@ def iterated_execution( if is_match["result"] == 1: diff_list = [ + # Bug fix: denominator must use predicted_sql, not gold_sql. + # The original code divided gold_time / gold_time (always 1.0), + # making VES meaningless. Correct formula: gold_time / predicted_time. self.execute_sql(sql=gold_sql, dsn_or_db_path=dsn_or_db_path)[ "execution_time" ] - / self.execute_sql(sql=gold_sql, dsn_or_db_path=dsn_or_db_path)[ + / self.execute_sql(sql=predicted_sql, dsn_or_db_path=dsn_or_db_path)[ "execution_time" ] for _ in range(num_iterations)