Answer the question
In order to leave comments, you need to log in
How to make fast unique fetch from postgresql?
There is a table:
You need to quickly get the last unique values for the "radio" field from the table.
That is, for the "radio" field, the last value is the value of the "track" field.
Having rummaged through the Internet, I found only this option:
But it runs for 5 minutes, which is not very good.
I would be grateful for any advice
Answer the question
In order to leave comments, you need to log in
Is there a list of necessary radios separately or do you need to search for the same plate?
If you search on the same plate, then you need loose index scan . A stupid planner himself cannot do this, you have to explain it manually.
If the list is separate, then a simple lateral join of the subquery will be more compact.
Here , from slides 30 to 46
, the btree(radio, date) index is required, if I understand correctly on what basis you want to determine the "last" value.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question