Timescaledb adds a custom scan for speeding up distinct on out of the box. Just install extension, no extra work is needed.
https://blog.timescale.com/blog/how-we-made-distinct-queries...
I tried it and it really is that fast.
https://blog.timescale.com/blog/how-we-made-distinct-queries...
I tried it and it really is that fast.
This is cool, thanks! Bit of a limitation that it only works on a single DISTINCT ON column, hopefully they'll be able to extend it to more in the future. And hope it makes it in for everyone that's on stock postgresql!