Re: Efficient sorting the results of a join, without denormalization

From: "Glen M(dot) Witherington" <glen(at)fea(dot)st>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Efficient sorting the results of a join, without denormalization
Date: 2015-05-31 04:43:25
Message-ID: 1433047405.880573.282526153.009601AE@webmail.messagingengine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, May 30, 2015, at 11:33 PM, David G. Johnston wrote:
> This is one problem with using made up surrogate keys...
>
> The PK of A is a component of both the PK of B and the PK of C but you throw that information away by using serial fields for PKs instead.  You should have unique indexes on B and C that incorporate the ID from A

That is quite a strange schema, though isn't it? If you imagine it as
emails:

C = Emails
B = Folder
A = User

Now you're suggesting that even though an email belongs to to a folder,
which belongs to a user ... each email should also contain contain a
reference to a user? I guess that's fine, but seems unideal from a
redundancy perspective

>
> All that said you really should put indexes on the foreign keys...

Yeah, of course. I purposely left that out, as I was asking which
indexes would need to be created to support that query

Thanks for your help!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rishi Gokhale 2015-05-31 05:05:17 date type changing to timestamp without time zone in postgres 9.4
Previous Message David G. Johnston 2015-05-31 04:33:13 Re: Efficient sorting the results of a join, without denormalization