comparison PostgreSQL/Plugins/SQL/PrepareIndex.sql @ 575:4c84d908e891 find-refactoring

fix statistics in read-only
author Alain Mazy <am@orthanc.team>
date Mon, 30 Sep 2024 18:02:36 +0200
parents 6667bd31beaf
children b0533b703c2c
comparison
equal deleted inserted replaced
574:58fce5aebb31 575:4c84d908e891
556 DECLARE 556 DECLARE
557 current_value BIGINT; 557 current_value BIGINT;
558 558
559 BEGIN 559 BEGIN
560 560
561 SELECT VALUE from GlobalIntegers 561 SELECT VALUE FROM GlobalIntegers
562 INTO current_value 562 INTO current_value
563 WHERE key = statistics_key; 563 WHERE key = statistics_key;
564 564
565 SELECT sum(value) + current_value FROM GlobalIntegersChanges 565 SELECT COALESCE(SUM(value), 0) + current_value FROM GlobalIntegersChanges
566 INTO accumulated_value 566 INTO accumulated_value
567 WHERE key = statistics_key; 567 WHERE key = statistics_key;
568 568
569 END; 569 END;
570 $body$ LANGUAGE plpgsql; 570 $body$ LANGUAGE plpgsql;