Using inner join and indexing on query