pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Optimze usage of immutable functions as relation
Date: Thu, 01 Aug 2019 18:57:16 -0400
Message-ID: <24410.1564700236@sss.pgh.pa.us> (raw)
In-Reply-To: <18cbbbf6-5c03-41d5-5bd4-30048c2e5155@postgrespro.ru>
References: <402356c32eeb93d4fed01f66d6c7fe2d@postgrespro.ru>
	<20180906185109.661aaef0@asp437-ThinkPad-L380>
	<153994199621.10161.17815885396545049364.pgcf@coridan.postgresql.org>
	<CACdpekK1oDy7-_HnXOaREa_8HM2r-fsp8iv5e6p8aWOdGdK8Mg@mail.gmail.com>
	<2906.1542395026@sss.pgh.pa.us>
	<3f7fda2f-1cdc-8ad3-e3c9-c2436fb5d509@postgrespro.ru>
	<CA+hUKGK1ATcNa678n=AG+DHQrFmWr-Lovmsq2AP-m5r=shW0Mg@mail.gmail.com>
	<0dd4efb2-22a3-6fef-11f7-1b20dd71a509@postgrespro.ru>
	<d31c5077-398f-dd26-ef9f-df11918b42f0@postgrespro.ru>
	<18924.1564165560@sss.pgh.pa.us>
	<18cbbbf6-5c03-41d5-5bd4-30048c2e5155@postgrespro.ru>

Anastasia Lubennikova <a.lubennikova@postgrespro.ru> writes:
> Thank you for pointing out on specific of int4() function,
> I updated tests to use dummy plpgsql function.
> I'm not sure if tests of various join types are redundant but I left them.
> As far as I understand, the principal motivation of this patch was to 
> optimize
> function scan joins that occur in FTS queries. For example:
> select * from test_tsquery, to_tsquery('english', 'new') q where 
> txtsample @@ q;
> So I also added another test to tsearch.sql to illustrate difference 
> between optimized and not optimized plans.

Fair enough.

I've pushed this after a good deal of further hackery on the code.
Notably

* I had no faith that we still guaranteed to perform
eval_const_expressions on every function-RTE expression.  Even if
that were true today, it'd be awfully easy to break in future,
if it only happened somewhere down in the recursion in
pull_up_subqueries_recurse.  So I moved that responsibility to
an earlier spot that clearly traverses all function RTEs.
A happy side benefit is that inline_set_returning_function
gets simpler because it can assume that that already happened.

* It looked to me like the pullup_constant_function code wasn't
covering all the places where it might need to replace Vars
referencing the function RTE.  I refactored things to avoid
having a bunch of code duplication while ensuring it hits
everyplace that pull_up_simple_subquery does.

			regards, tom lane





view thread (29+ messages)  latest in thread

Message-ID: <24410.1564700236@sss.pgh.pa.us>
Permalink:  ../24410.1564700236@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24410.1564700236@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, a.lubennikova@postgrespro.ru, pgsql-hackers@lists.postgresql.org
  Subject: Re: Optimze usage of immutable functions as relation
  In-Reply-To: <24410.1564700236@sss.pgh.pa.us>

* 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