I have a mysql query that's taking several minutes which isn't very good as it's used to create a web page.

Three tables are used: poster\_data contains information on individual posters. poster\_categories lists all the categories (movies, art, etc) while poster\_prodcat lists the posterid number and the categories it can be in e.g. one poster would have multiple lines for say, movies, indiana jones, harrison ford, adventure films, etc. 

this is the slow query: 

```
select * 
  from poster_prodcat, 
       poster_data, 
       poster_categories 
 where poster_data.apnumber = poster_prodcat.apnumber 
   and poster_categories.apcatnum = poster_prodcat.apcatnum 
   and poster_prodcat.apcatnum='623'  
ORDER BY aptitle ASC 
   LIMIT 0, 32

```

According to the explain:

![explain](https://i.stack.imgur.com/pujUi.jpg)

It was taking a few minutes. Poster\_data has just over 800,000 rows, while poster\_prodcat has just over 17 million. Other category queries with this select are barely noticeable, while poster\_prodcat.apcatnum='623' has about 400,000 results and is writing out to disk