Re: Efficient sorting the results of a join, without denormalization - Mailing list pgsql-general

From Francisco Olarte
Subject Re: Efficient sorting the results of a join, without denormalization
Date
Msg-id CA+bJJbwte8NiKQU_reXYgWMR-bnJZmRZsCz+hcSokerPq7+8ug@mail.gmail.com
Whole thread Raw
In response to Re: Efficient sorting the results of a join, without denormalization  ("Glen M. Witherington" <glen@fea.st>)
List pgsql-general
Hi Glen:

On Mon, Jun 1, 2015 at 1:16 AM, Glen M. Witherington <glen@fea.st> wrote:

> Thanks Francisco, that makes sense. I've started moving my code to that,
> and it eliminates all the performance issues I had.

Happty to hear it. Seems you have a kind of speed-size trade off. If
you can solve it while preserving integrity, great for you.

> I guess I was really hoping there would exist some sort of "dereference"
> option when indexing, so I could dereference a foreign key, and then
> index on a attribute of that row. E.g. So I could have created an index
> such as:
> deref(deref(mail.folder_id).user_id, created_at)

That is difficult, as it would need a way to force mail.folder.user_id
to be a constant or have a lot of rules/triggers ( manual, automatic
or just plain magic ) to update your indexes. On this cases composite
keys let you use composite indexes to accelerate your queries while
preserving normalization, if you can afford them they are nice. The
big problem comes many times if you try to mix them with ORMs and
similar.

Francisco Olarte.


pgsql-general by date:

Previous
From: Andres Freund
Date:
Subject: Re: [HACKERS] Re: 9.4.1 -> 9.4.2 problem: could not access status of transaction 1
Next
From: "ben.play"
Date:
Subject: Re: My index doesn't write anymore but read