This is the query I want to optimize:
SELECT *
FROM invited_member_events
WHERE (user_id = '422820341791064085'
OR inviter_user_id = '422820341791064085')
AND guild_id = '638685268777500672';
I created an index for the guild_id column, a second index with the columns user_id_inviter_user_id, a third index with the user_id column. And it does not use them, it only uses the guild_id one. Do you know how can I create an index so it works with the OR condition?
as you can see, only the guild_id index is used, not the other ones.



(guild_id, user_id)and on(guild_id, invited_user_id). If they are not used, I'd retry (with those same 2 indexes) rewriting the query without the OR using UNION.\d invited_member_events