pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rui DeSousa <rui@crazybean.net>
To: Wells Oliver <wells.oliver@gmail.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Very slow 101-feeling design/query..
Date: Fri, 10 Dec 2021 23:18:14 -0500
Message-ID: <351E9FBA-1FF4-4A7B-BD78-ED60F36BA7F7@crazybean.net> (raw)
In-Reply-To: <CAOC+FBWG-0BH_prvkbMTFuAQ37pr+Kx3S=V=krE1qkGhojXtJw@mail.gmail.com>
References: <CAOC+FBWG-0BH_prvkbMTFuAQ37pr+Kx3S=V=krE1qkGhojXtJw@mail.gmail.com>



> On Dec 10, 2021, at 5:53 PM, Wells Oliver <wells.oliver@gmail.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.

view thread (14+ messages)  latest in thread

Message-ID: <351E9FBA-1FF4-4A7B-BD78-ED60F36BA7F7@crazybean.net>
Permalink:  ../351E9FBA-1FF4-4A7B-BD78-ED60F36BA7F7@crazybean.net/
Also on:    postgresql.org/message-id/351E9FBA-1FF4-4A7B-BD78-ED60F36BA7F7@crazybean.net

 · 

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-admin@postgresql.org
  Cc: rui@crazybean.net, wells.oliver@gmail.com
  Subject: Re: Very slow 101-feeling design/query..
  In-Reply-To: <351E9FBA-1FF4-4A7B-BD78-ED60F36BA7F7@crazybean.net>

* 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