pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: partition tree inspection functions
Date: Thu, 28 Jun 2018 23:19:17 +0200
Message-ID: <27f51cb0-b448-66ac-5bc8-12edeb656873@2ndquadrant.com> (raw)
In-Reply-To: <20180628113035.GA1716@paquier.xyz>
References: <8d00e51a-9a51-ad02-d53e-ba6bf50b2e52@lab.ntt.co.jp>
	<b24e77c4-3ac1-7c2e-9359-629385578175@2ndquadrant.com>
	<e0762082-09fc-030d-15e5-ee450d63b440@lab.ntt.co.jp>
	<d3dfbc48-ebfe-79ed-3a44-f81880e6aba6@2ndquadrant.com>
	<20180628113035.GA1716@paquier.xyz>

On 6/28/18 13:30, Michael Paquier wrote:
> On Thu, Jun 28, 2018 at 12:37:14PM +0200, Peter Eisentraut wrote:
>> I'm thinking, an SQL query might be more efficient if you want to
>> qualify the query further.  For example, give me all tables in this tree
>> that match '2018'.  If you wrote your functions as SQL-language
>> functions, the optimizer could perhaps inline them and optimize them
>> further.
> 
> Are you thinking about SQL functions here?  Here is an example of query
> able to fetch an entire partition tree.
> WITH RECURSIVE partition_info
>           (relid,
>            relname,
>            relsize,
>            relispartition,
>            relkind) AS (
>         SELECT oid AS relid,
>                relname,
>                pg_relation_size(oid) AS relsize,
>                relispartition,
>                relkind
>         FROM pg_catalog.pg_class
> 	WHERE relname = 'your_parent_table_name_here' AND
> 	      relkind = 'p'
[...]

Yes, this kind of thing should be more efficient than building the
entire tree in a C function and then filtering it afterwards.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (74+ messages)  latest in thread

Message-ID: <27f51cb0-b448-66ac-5bc8-12edeb656873@2ndquadrant.com>
Permalink:  ../27f51cb0-b448-66ac-5bc8-12edeb656873@2ndquadrant.com/
Also on:    postgresql.org/message-id/27f51cb0-b448-66ac-5bc8-12edeb656873@2ndquadrant.com

 · 

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: peter.eisentraut@2ndquadrant.com, michael@paquier.xyz, Langote_Amit_f8@lab.ntt.co.jp
  Subject: Re: partition tree inspection functions
  In-Reply-To: <27f51cb0-b448-66ac-5bc8-12edeb656873@2ndquadrant.com>

* 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