I'm pretty new to indexing so maybe this is a stupid question but anyway. I got this schema and my task is to get all the students that study in their hometown (above schools and students there is a cities table).
I came up with this:
select st.id, st.last_name, st.first_name, st.birth_year, st.birth_city_id
from students as st
join school_students ss on st.id = ss.student_id
join schools sc on sc.id = ss.school_id
where st.birth_city_id=sc.city_id;
Then for optimization I tried:
CREATE INDEX schools_id ON schools(city_id);
CREATE INDEX school_students_id ON school_students(student_id, school_id) ; --does this helps somehow?
CREATE INDEX students_id ON students(birth_city_id);
But it does not work properly...
The query plan shows Seq scan instead of Index scan. So is there any way to do this Index across multiple tables or something similar?
Thanks in advance.

CREATE INDEXis actually onschool_students?