If the database system is taking too long to process an SQL statement, analyze your database.
..
1. You use the EXPLAIN statement to find out which search strategy the Optimizer is using for the SQL statement.
2. You check your database design.
See Concepts of the Database System, Database Design Tips