Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f2Q7D-0000Yj-QB for pgsql-general@arkaria.postgresql.org; Sat, 31 Mar 2018 23:40:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f2Q7C-00066M-Bd for pgsql-general@arkaria.postgresql.org; Sat, 31 Mar 2018 23:40:54 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f2Q7B-000643-WC for pgsql-general@lists.postgresql.org; Sat, 31 Mar 2018 23:40:54 +0000 Received: from n3.nabble.com ([162.255.23.22]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f2Q73-0001nS-T5 for pgsql-general@postgresql.org; Sat, 31 Mar 2018 23:40:52 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 9FF53C0DBA9F for ; Sat, 31 Mar 2018 16:40:43 -0700 (MST) Date: Sat, 31 Mar 2018 16:40:43 -0700 (MST) From: pinker To: pgsql-general@postgresql.org Message-ID: <1522539643653-0.post@n3.nabble.com> Subject: unreliable behaviour of track_functions MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi All! I've been experimenting with track_functions options and what I've saw it's really puzzling me. Documentation says: / SQL-language functions that are simple enough to be "inlined" into the calling query will not be tracked, regardless of this setting./ But it came up, it depends on much more factors, like duration or placing it in the query, it is totally non-deterministic behaviour. This really simple SQL function: CREATE FUNCTION a(a bigint) RETURNS bigint STABLE LANGUAGE SQL AS $$ SELECT $1 $$; Is not shown in the pg_stat_user_functions at all. It is started to be shown when one line: select pg_sleep(1); is added??? Another one, gets tracked only if I use: SELECT get_unique_term(2556); If it lands in FROM then it's not tracked... SELECT * FROM get_unique_term(2556); That's the body of the function: CREATE FUNCTION get_unique_term(i_game_pin bigint) RETURNS TABLE(term text, category text) STABLE LANGUAGE SQL AS $$ SELECT i.term, i.dict_category_id FROM (SELECT categories.term, categories.dict_category_id FROM categories EXCEPT ALL SELECT games.term, games.category FROM games WHERE game_pin = $1) i ORDER BY (random()) LIMIT 1; $$; What's going on here? That's pretty unreliable behaviour... My version of postgres: PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit show track_functions; track_functions ----------------- all (1 wiersz) -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html