MySQL query is very slow (15 minutes)
You need to add indexes:

image (person_id, image_id)
has (image_id, tag_id) - you can remove id column from this table and make this index a primary key
It is not the best idea to use &quot;text&quot; data type for person.name column. It would be better to use varchar or nvarchar. For example, varchar(100) should be enough. Then create index on this column too: person (name).