vendredi 14 août 2015

Creating 2 indexes for a join table

Suppose I have many-to-many relationship between "contributors" and "pages". I have a join table with 2 columns: contributor_id and page_id. Through my application, I'll often want to:

a) For a given contributor, find its pages b) For a given page, find its contributors

I know that creating a (two) multi-column index would work here, but in what order should the index be? Should I maybe create 2 multi-column indexes, one where contributor_id goes first and the other where page_id goes first?

Aucun commentaire:

Enregistrer un commentaire