Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7viH-0002Us-Dg for pgsql-bugs@arkaria.postgresql.org; Wed, 01 Jun 2016 02:16:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b7viH-0008E8-00 for pgsql-bugs@arkaria.postgresql.org; Wed, 01 Jun 2016 02:16:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b7vhd-00073I-I8 for pgsql-bugs@postgresql.org; Wed, 01 Jun 2016 02:16:13 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1b7vha-0002oV-3w for pgsql-bugs@postgresql.org; Wed, 01 Jun 2016 02:16:13 +0000 Received: from localhost ([127.0.0.1]:33778 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.84 (FreeBSD)) (envelope-from ) id 1b7vhX-000EC1-NY; Wed, 01 Jun 2016 02:16:07 +0000 From: Andrew Gierth To: Daniel Migowski Cc: Michael Paquier , PostgreSQL mailing lists Subject: Re: BUG #14162: No statistics for functions used as aggregates In-Reply-To: <41ED3F5450C90F4D8381BC4D8DF6BBDCAF46539E@EXCHANGESERVER.ikoffice.de> (Daniel Migowski's message of "Tue, 31 May 2016 05:47:58 +0000") Message-ID: <87eg8h4qwn.fsf@news-spur.riddles.org.uk> References: <20160528135240.19422.27547@wrigleys.postgresql.org> <41ED3F5450C90F4D8381BC4D8DF6BBDCAF464F15@EXCHANGESERVER.ikoffice.de> <41ED3F5450C90F4D8381BC4D8DF6BBDCAF46539E@EXCHANGESERVER.ikoffice.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) Date: Wed, 01 Jun 2016 03:16:07 +0100 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org >>>>> "Daniel" == Daniel Migowski writes: Daniel> Ok, then no statistics for me :). If this is intentional, a Daniel> small line or warning in the docs would be helpful. There's a workaround, though it's a somewhat bizarre one: If you apply any SET clause to the definition of a function, then calls to it will be tracked (if either track_functions is globally enabled or if the SET clause enables it) regardless of the context the function is called in. This is also true for security definer functions. This doesn't seem to be entirely intentional, it is fallout from the ability to do SET track_functions = ... in the definition of a specific function and have it take effect for that specific call. (There is some overhead with this, since SET clauses or secdef are implemented using a shim between the function and its caller, but the overhead should be much less than a plpgsql wrapper. Also, this will disable inlining of the function if it is LANGUAGE SQL.) Daniel> I also wonder if in and out functions of datatypes are tracked Daniel> (As they a C functions) or if there are other places where Daniel> function tracking isn't implemented although the functions get Daniel> called (maybe on index creation, etc.). I need this information Daniel> because I currently try to decide if I have to convert some of Daniel> these functions to native c functions. As far as I can tell, only the following cases are tracked: - functions called as triggers or event triggers - functions called from the expression evaluator - functions called as FROM-clause entries in queries - any function which has a SET clause or is SECURITY DEFINER Not tracked are any other cases, which include: - the function-call fastpath from clients - window functions and aggregate functions - functions used for sort/group/distinct/hash comparisons - index support functions - input and output functions - estimation functions - any case where a function calls another function without going via SQL -- Andrew (irc:RhodiumToad) -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs