I have a following MySQL code for table:
CREATE TABLE `tag_to_photo` (
`tag_id` INT UNSIGNED NOT NULL,
`photo_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`tag_id`, `photo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
How to optimally define indices if I am going to search for both: all tags pinned to photo and all photos pinned to tag? I assume primary key can be combined. But should I define additional index for tag_id
or photo_id
or maybe for both?