From 37160c7b357b04d96b227d3279f4cddc9c68f7ca Mon Sep 17 00:00:00 2001 From: Luis Bosque Date: Sun, 27 Sep 2015 19:22:22 +0200 Subject: [PATCH] Write invalidation duration in postgresql log --- scripts-available/CDB_TableMetadata.sql | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts-available/CDB_TableMetadata.sql b/scripts-available/CDB_TableMetadata.sql index d91f798..7eb22b7 100644 --- a/scripts-available/CDB_TableMetadata.sql +++ b/scripts-available/CDB_TableMetadata.sql @@ -64,6 +64,10 @@ DECLARE tabname TEXT; rec RECORD; found BOOL; + function_start timestamptz; + function_end timestamptz; + function_duration float; + log_error_verbosity text; BEGIN IF TG_OP = 'UPDATE' or TG_OP = 'INSERT' THEN @@ -72,6 +76,8 @@ BEGIN tabname = OLD.tabname; END IF; + EXECUTE 'SELECT clock_timestamp()' INTO function_start; + -- Notify table data update -- This needs a little bit more of research regarding security issues -- see https://github.com/CartoDB/cartodb/pull/241 @@ -105,7 +111,15 @@ BEGIN EXIT; END LOOP; IF NOT found THEN RAISE WARNING 'Missing cdb_invalidate_varnish()'; END IF; - + + EXECUTE 'SELECT clock_timestamp()' INTO function_end; + SELECT extract(epoch from (function_end - function_start)) INTO function_duration; + + EXECUTE 'SELECT setting FROM pg_settings where name=''log_error_verbosity''' INTO log_error_verbosity; + SET log_error_verbosity=TERSE; + RAISE LOG 'invalidation_duration: %', function_duration::text; + EXECUTE 'SET log_error_verbosity= ' || log_error_verbosity; + RETURN NULL; END; $$