From: | Mladen Gogala <gogala(dot)mladen(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Faster distinct query? |
Date: | 2021-09-23 03:02:12 |
Message-ID: | 135cb451-c8d0-28ed-f563-0bd3bf2f2438@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 9/22/21 16:20, David G. Johnston wrote:
> I'd probably turn that index into a foreign key that just ensures that
> every (station,channel) that appears in the data table also appears on
> the lookup table. Grouping and array-ifying the lookup table would be
> trivial. Either modify the application code or add a trigger to
> populate the lookup table as needed.
I fully agree with this. Adding a trigger to populate a lookup table is
a standard design in situations like this. Using "DISTINCT" almost
always spells trouble for the performance.
--
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
From | Date | Subject | |
---|---|---|---|
Next Message | hubert depesz lubaczewski | 2021-09-23 07:04:35 | Re: Faster distinct query? |
Previous Message | Ryan Booz | 2021-09-23 01:49:48 | Re: Faster distinct query? |