Re: Very slow 101-feeling design/query..

From: Rui DeSousa <rui(at)crazybean(dot)net>
To: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Very slow 101-feeling design/query..
Date: 2021-12-11 04:18:14
Message-ID: 351E9FBA-1FF4-4A7B-BD78-ED60F36BA7F7@crazybean.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

> On Dec 10, 2021, at 5:53 PM, Wells Oliver <wells(dot)oliver(at)gmail(dot)com> wrote:
>
> SELECT DISTINCT game_id FROM vw_joints

Seeing distinct makes me cringe; most uses of it foreshadow either a poor design or a bad query; not always but more often than not.

If you’re really trying to do a distinct you can select from the game table and do an exists against plays and joints tables thus removing the distinct clause; but I digress as the given query is most likely an over simplified query just as example.

Partitioning does nothing here as the query doesn’t filter on the partitioned field thus no partition elimination.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Michel SALAIS 2021-12-11 15:58:48 RE: Very slow 101-feeling design/query..
Previous Message Tom Lane 2021-12-11 02:56:53 Re: Very slow 101-feeling design/query..