pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Cluster table based on grand parent?
Date: Tue, 28 Mar 2023 12:00:21 -0500
Message-ID: <334a4103-6f8a-4942-c153-ca0692352d79@gmail.com> (raw)
In-Reply-To: <CAFCRh-9+CQnoPtavF2rhahcHf7Rvszrk3XBdyJa5B=e5zV38Cg@mail.gmail.com>
References: <CAFCRh-_MVYOEVoX9Y8neu_ZmSCvr6iFCSMQQxVW6veoPg-8g0w@mail.gmail.com>
	<a46c2fb9-e77c-12fe-c18d-1c43dcc54ec5@gmail.com>
	<CAFCRh-9+CQnoPtavF2rhahcHf7Rvszrk3XBdyJa5B=e5zV38Cg@mail.gmail.com>

On 3/28/23 11:28, Dominique Devienne wrote:
> On Tue, Mar 28, 2023 at 6:06 PM Ron <ronljohnsonjr@gmail.com> wrote:
>
>     You can only get from parent to grandchild via//child.id
>     <http://child.id; to grandchild.parent, so why not cluster grandchild
>     on grandchild.parent?
>
>
> Hi. I don't understand your question. Yes, of course, if I want all 
> grand-children of a given parent, I'll do for example:
>
> select p.id <http://p.id;, c.id <http://c.id;, c.name <http://c.name;, gc.*
>   from  grandchild gc
>    join child c on gc.parent = c.id <http://c.id;
>    join parent p on c.parent = p.id <http://p.id;
> where p.name <http://p.name; = $1
>
> But w/o clustering on a denormalized grandchild.grandparent FK column, as 
> Peter showed,
> and cluster only on grandchild.parent, that's not going to access a mostly 
> continuous range
> of pages to fetch those all grandchild rows for that one parent. But 
> probably 10 to 50 "row-clusters",
> given the fan-out I mentioned earlier at the child-table level. Or am I 
> missing something?

No, you're not missing something.  If you want to go directly from 
grandparent to grandchild, then you need to put grandparent_id in the 
grandchild table.

Rob Sargent is right, too, though: *practically* it might not make a 
difference.  You've got to test.

-- 
Born in Arizona, moved to Babylonia.

view thread (8+ messages)

Message-ID: <334a4103-6f8a-4942-c153-ca0692352d79@gmail.com>
Permalink:  ../334a4103-6f8a-4942-c153-ca0692352d79@gmail.com/
Also on:    postgresql.org/message-id/334a4103-6f8a-4942-c153-ca0692352d79@gmail.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 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-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: Cluster table based on grand parent?
  In-Reply-To: <334a4103-6f8a-4942-c153-ca0692352d79@gmail.com>
  References: <CAFCRh-_MVYOEVoX9Y8neu_ZmSCvr6iFCSMQQxVW6veoPg-8g0w@mail.gmail.com> <a46c2fb9-e77c-12fe-c18d-1c43dcc54ec5@gmail.com> <CAFCRh-9+CQnoPtavF2rhahcHf7Rvszrk3XBdyJa5B=e5zV38Cg@mail.gmail.com> <334a4103-6f8a-4942-c153-ca0692352d79@gmail.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