If you can't modify the query, then there is nothing more to be done to optimize the execution afaik. Distinct is much slower than group by in scenarios like this with many columns. You already identified the disk sort and increased work mem to get it faster by 3x. There are not any other tricks of which I am aware.
- select distinct runs slow on pg 10.6 yash mehta
- Re: select distinct runs slow on pg 10.6 yash mehta
- Re: select distinct runs slow on pg 10.6 Flo Rance
- Re: select distinct runs slow on pg 10.6 yash mehta
- Re: select distinct runs slow on pg 10.6 Justin Pryzby
- Re: select distinct runs slow on pg 10.6 Flo Rance
- Re: select distinct runs slow on pg 10.6 Michael Lewis
- Re: select distinct runs slow on pg 10.6 yash mehta
- Re: select distinct runs slow on pg 1... Rick Otten
- Re: select distinct runs slow on pg 10.6 Merlin Moncure
- Re: select distinct runs slow on pg 10.6 Dinesh Somani
- Re: select distinct runs slow on pg 10.6 Rick Otten
- Re: select distinct runs slow on pg 10.6 Merlin Moncure
- Re: select distinct runs slow on pg 1... Dinesh Somani