pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Daniel Migowski <dmigowski@ikoffice.de>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14162: No statistics for functions used as aggregates
Date: Wed, 01 Jun 2016 03:16:07 +0100
Message-ID: <87eg8h4qwn.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <41ED3F5450C90F4D8381BC4D8DF6BBDCAF46539E@EXCHANGESERVER.ikoffice.de>
References: <20160528135240.19422.27547@wrigleys.postgresql.org>
	<CAB7nPqR=bRraNG2Vp4FUukjA9QOJsRouh-skGzRjrtHR9ArQNA@mail.gmail.com>
	<41ED3F5450C90F4D8381BC4D8DF6BBDCAF464F15@EXCHANGESERVER.ikoffice.de>
	<CAB7nPqRwvFnEtUOH2XrWfghCk-PR4n8DP4zMJQ8duzQK2wc3DQ@mail.gmail.com>
	<41ED3F5450C90F4D8381BC4D8DF6BBDCAF46539E@EXCHANGESERVER.ikoffice.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

>>>>> "Daniel" == Daniel Migowski <dmigowski@ikoffice.de> 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



view thread (7+ messages)  latest in thread

Message-ID: <87eg8h4qwn.fsf@news-spur.riddles.org.uk>
Permalink:  ../87eg8h4qwn.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87eg8h4qwn.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, dmigowski@ikoffice.de, michael.paquier@gmail.com
  Subject: Re: BUG #14162: No statistics for functions used as aggregates
  In-Reply-To: <87eg8h4qwn.fsf@news-spur.riddles.org.uk>
  References: <20160528135240.19422.27547@wrigleys.postgresql.org> <CAB7nPqR=bRraNG2Vp4FUukjA9QOJsRouh-skGzRjrtHR9ArQNA@mail.gmail.com> <41ED3F5450C90F4D8381BC4D8DF6BBDCAF464F15@EXCHANGESERVER.ikoffice.de> <CAB7nPqRwvFnEtUOH2XrWfghCk-PR4n8DP4zMJQ8duzQK2wc3DQ@mail.gmail.com> <41ED3F5450C90F4D8381BC4D8DF6BBDCAF46539E@EXCHANGESERVER.ikoffice.de> <87eg8h4qwn.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox