From aa6bda699978ada356c98d0502260ac2ebab7861 Mon Sep 17 00:00:00 2001 From: Bartek Wrona <wrona@syncad.com> Date: Thu, 23 Jul 2020 22:53:00 +0200 Subject: [PATCH] Fixed SQL function attribute --- hive/db/db_state.py | 7 +++++++ hive/db/schema.py | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hive/db/db_state.py b/hive/db/db_state.py index aa721e314..d0f7f323c 100644 --- a/hive/db/db_state.py +++ b/hive/db/db_state.py @@ -3,6 +3,8 @@ #pylint: disable=too-many-lines import time +from time import perf_counter + import logging import sqlalchemy @@ -174,12 +176,17 @@ class DbState: index.create(engine) + time_start = perf_counter() + # Update count of all child posts (what was hold during initial sync) sql = """ select update_hive_posts_children_count() """ row = DbState.db().query_row(sql) + time_end = perf_counter() + log.info("[INIT] update_hive_posts_children_count executed in %fs", time_end - time_start) + # TODO: #111 #for key in cls._all_foreign_keys(): # log.info("Create fk %s", key.name) diff --git a/hive/db/schema.py b/hive/db/schema.py index 6cbb703ec..f52669aa9 100644 --- a/hive/db/schema.py +++ b/hive/db/schema.py @@ -658,9 +658,7 @@ def setup(db): CREATE OR REPLACE FUNCTION public.update_hive_posts_children_count() RETURNS void LANGUAGE 'plpgsql' - - COST 100 - STABLE + VOLATILE AS $BODY$ BEGIN -- GitLab