Effective search for a value retrieved from COALESCE in PostgreSQL
I'm implementing a dialogs search module on a messaging app. Retrieving the list of dialogs names would be as follows: select coalesce(c.custom_name, u.username) as dialog_name from user_chats uc join chats c using(chat_id) left join users u on uc.peer_id = u.user_id…