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 1f2frG-0000AY-RI for pgsql-general@arkaria.postgresql.org; Sun, 01 Apr 2018 16:29:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f2frF-0005WE-GN for pgsql-general@arkaria.postgresql.org; Sun, 01 Apr 2018 16:29:29 +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 1f2frD-0005W2-FF for pgsql-general@lists.postgresql.org; Sun, 01 Apr 2018 16:29:29 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f2fr5-0007O8-Af for pgsql-general@postgresql.org; Sun, 01 Apr 2018 16:29:25 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E417D20E75; Sun, 1 Apr 2018 12:29:17 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 01 Apr 2018 12:29:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=WA4Qw/w0CFpy9BFEdYbptIotaTJdR tjGIQkHzsS3joE=; b=C8wO9uW6zy97lN6Tomf1ciH3nuUQS5qY8GNQFBuwCu/BO e2FqZVEmKn5cDIqBPwO9rVEMeQjsWZgTWDBIyB6SLaDhNjJDrajwFQS/0amHMu4v 8Lhtqn8UfgVg3O6h8XU5r0yh0FlSrhqm/WDZh/rHioopfmk+Olgt07P3e0hoNIir deRX05AZh0DYM7VOUUbl2hBPano8RPW0pkgj/esXJKHdmROFOIYvNNvMKJjwcBZf CmD1H2eA8wsrMd08sI6mKgn/BmLQhWMlO4+kHzkUbqb+IndE5VRocvIe21jiVVFX 8m78kG5qZCrFVUL4JKF4+QHf6Pmo2i2huJcEYU5rA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=WA4Qw/ w0CFpy9BFEdYbptIotaTJdRtjGIQkHzsS3joE=; b=PNa2efdaQ0nAkXv3f8HSfK SgIXQj0najh0p9hdlTlngghAiGcRqKy6Q8l3smNQQWJZVo65z5mm2/LS0IJbFTWE xBG3pRUSPee1BRtjLO+0F+qkAaw2iRPfNhUpDe2jowLhJyywhhJJdIlO3qO6nhKj /hXrxrsJwHVQABCPi/R0gB6LjmwJdca6IV2cm5yA/bZu3KyiCHn4E2j7p1Ii7ZTc kmdVTZYnbwXFV5xt9xo0UruT696Xb5LcswbEK7Ll/bjhgpu2Nr++IpHff3swupEy tfFP6DIkA4J4m0pBauk/hkrcUNg5pb1ZCf6Mnb/SVW/qy0sf7DPh5CjkCiXP6efQ == X-ME-Sender: Received: from [192.168.1.2] (71-35-123-124.tukw.qwest.net [71.35.123.124]) by mail.messagingengine.com (Postfix) with ESMTPA id 6F18810252; Sun, 1 Apr 2018 12:29:17 -0400 (EDT) Subject: Re: unreliable behaviour of track_functions To: pinker , pgsql-general@postgresql.org References: <1522539643653-0.post@n3.nabble.com> <650a05f5-2926-5a63-e653-2ae5aa903547@aklaver.com> <1522541842492-0.post@n3.nabble.com> <1522587735746-0.post@n3.nabble.com> From: Adrian Klaver Message-ID: <370eb893-48e8-8fa2-9ecf-c3e77e74cdc1@aklaver.com> Date: Sun, 1 Apr 2018 09:29:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1522587735746-0.post@n3.nabble.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 04/01/2018 06:02 AM, pinker wrote: > I mean this part describing track_function: > > https://www.postgresql.org/docs/10/static/runtime-config-statistics.html > > Enables tracking of function call counts and time used. Specify pl to track > only procedural-language functions, all to also track SQL and C language > functions. The default is none, which disables function statistics tracking. > Only superusers can change this setting. > > Note > SQL-language functions that are simple enough to be “inlined” into the > calling query will not be tracked, regardless of this setting. > > Only case described here, that exclude function from being tracked it's > inlining, not the time and not the place in the query. The below might help: https://wiki.postgresql.org/wiki/Inlining_of_SQL_functions In particular for your second case(place in query): " Table functions A table function call is any instance where func(args) appears where a table is expected. (This is, for most functions, a PostgreSQL extension to the SQL standard.) For example: select * from func(123); " For your first case: Inlining conditions for scalar functions "the function body consists of a single, simple, SELECT expression" So from your OP: CREATE FUNCTION a(a bigint) RETURNS bigint STABLE LANGUAGE SQL AS $$ SELECT $1 $$; If you change to: CREATE FUNCTION a(a bigint) RETURNS bigint STABLE LANGUAGE SQL AS $$ SELECT 'test'; SELECT $1 $$; then before change: test=> select * from pg_stat_user_functions ; funcid | schemaname | funcname | calls | total_time | self_time ---------+------------+----------+-------+------------+----------- 1386647 | public | a | 2 | 1251.598 | 1251.598 (1 row) after change: test=> select * from pg_stat_user_functions ; funcid | schemaname | funcname | calls | total_time | self_time ---------+------------+----------+-------+------------+----------- 1386647 | public | a | 3 | 1251.682 | 1251.682 > So I would expect that pg_stat_user_function will show me that my function > was executed. Good that are other ways to do it, but changing > track_functions to 'all' I would expect all calls will be tracked... > > > > -- > Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html > > -- Adrian Klaver adrian.klaver@aklaver.com