diff --git a/hive/db/db_state.py b/hive/db/db_state.py index aa721e3140661b913f854cd1e95016bbf89a2b3e..d0f7f323cb7728975904834a4e105c2d5e7b6432 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 6cbb703ecc8030cfdf85d2c38eb0a42461ecda62..f52669aa90f83739763fcdbbbfd532d42adba241 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