New answers tagged limits
if column has unique index (constraint), You do not need to use LIMIT 1 LIMIT 1 - good tools for prevent potential errors when result MUST be single and You not sure about how many rows You have
The planner chooses use of a index depending on the distribution of data in your tables. If you have lots of receivers with only a few arrivals per receiver it will prefer a index like (receiver,arrival), if all arrivals are shared by only a handful of users the (arrival,receiver) index will be much more efficient. Make sure to run ANALYZE on the table ...
A btree index on (sender,arrival) could help. That would allow it to jump directly to the first-arrived message for a given sender. One on (arrival,sender) is less likely to help. That allows you to jump to the first-sent message globally, but then you still have to walk along those messages until you hit one from the specified sender. If that ...
Top 50 recent answers are included