I have a table in my database as users, resources and user_resources. users and resources tables connect as many to many relationship and user_resources is the connecting table.
Users table is as below
Suppose I create an index for columns age, gender, diagnosis, symptoms and treatments columns, as for my knowledge that index is applicable for the below search queries as well
SELECT * FROM Users WHERE age=12
SELECT * FROM Users WHERE age=12 AND gender='Female'
and I know that this index is not applicable for the queries like below
SELECT * FROM Users WHERE gender='Female' and age=12
I want to know if this index will be applicable for below type of queries as well
SELECT * FROM Users WHERE age=12 and treatments='treatment1'
SELECT * FROM Users WHERE gender='Female' OR diagnosis='diagnosis1'
since the indexes with multiple columns is applicable with leftmost columns. Further, if I join Users table with Resources table joining user_resources table but with same where clauses will it be applicable for the index. As an example
SELECT ur.userId, ur.resourceId, u.symptoms
FROM Users u
JOIN User_Resources ur ON u.userId = ur.userId
JOIN Resources r On ur.resourceId = r.resourceId
WHERE u.age = 12 AND
u.diagnosis like '%symptom1%'