Optimize last message search in member list view

This commit is contained in:
Ske 2020-06-13 02:45:06 +02:00
parent d246c9bf33
commit 292676b694

View File

@ -9,7 +9,8 @@ from systems
create view member_list as
select members.*,
-- Find last message ID
(select max(messages.mid) from messages where messages.member = members.id) as last_message,
-- max(mid) does full table scan, order by/limit uses index (dunno why, but it works!)
(select mid from messages where messages.member = members.id order by mid desc nulls last limit 1) as last_message,
-- Find last switch timestamp
(