Closed jc-harrison closed 3 months ago
Ooo, that's interesting.. We explicitly avoided us of DISTINCT because it used a slower code path as I recall. This test is still on a pg12 flowdb, right?
COUNT(DISTINCT ...)
uses a slower code path. I'm not sure the same is true of SELECT DISTINCT ON
.
Yes, this is still on a pg12 flowdb.
It appears we could get a modest performance improvement in
LastLocation
queries by re-implementing asinstead of the current
I ran a test on one day of calls data with ~14M events and ~2M subscribers, and saw a ~10% speed-up from 34.4s to 30.8s for the following query:
Explain output for the current implementation:
And for the modified implementation using
SELECT DISTINCT ON
:Of particular note:
rank=1
and plan accordingly.There are other instances in flowmachine where the "rank within window; select where rank=1" approach is used (e.g.
ModalLocation
) - it would be worth checking whether the same modification would help in those instances.