mardi 14 avril 2015

Better performance than double SQLite inner join

I have three tables (everything is oversimplified for the question)



Student
---
StudentId (primary key)
UniversityId (indexed)
CityId (indexed)
StudentName


University
---
UniversityId (primary key)
UniversityName


City
---
CityId (primary key)
CityName


I want to print out all the student names, but if names are the same, I want to order first by the CityName where they are from, and then by the UniversityName.


So, I have a simple query like this one:



select s.* from student s
inner join university u on s.UniversityId = u.UniversityId
inner join city c on s.CityId = c.CityId
order by s.StudentName asc, c.CityName asc, u.UniversityName asc


Is there a way to improve performance of this in any way, and how?


Aucun commentaire:

Enregistrer un commentaire