Skip to content

Commit a517f87

Browse files
committed
Move zero-size safeguard into cache_score function
1 parent f664158 commit a517f87

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

flowdb/bin/build/0030_utilities.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ $$
247247
cache_score_multiplier+POWER(1 + ln(2) / cache_half_life(), nextval('cache.cache_touches') - 2)
248248
END
249249
WHERE query_id=cached_query_id
250-
RETURNING cache_score(cache_score_multiplier, compute_time, greatest(table_size(tablename, schema), 0.00001)) INTO score;
250+
RETURNING cache_score(cache_score_multiplier, compute_time, table_size(tablename, schema), 0.00001) INTO score;
251251
IF NOT FOUND THEN RAISE EXCEPTION 'Cache record % not found', cached_query_id;
252252
END IF;
253253
RETURN score;
@@ -267,7 +267,7 @@ CREATE OR REPLACE FUNCTION cache_score(IN cache_score_multiplier numeric, IN com
267267
RETURNS float AS
268268
$$
269269
BEGIN
270-
RETURN cache_score_multiplier*((compute_time/1000)/tablesize);
270+
RETURN cache_score_multiplier*((compute_time/1000)/greatest(tablesize, 0.00001));
271271
END
272272
$$ LANGUAGE plpgsql
273273
SECURITY DEFINER

0 commit comments

Comments
 (0)