If the database system is taking too long to process an SQL statement, analyze your database and, if necessary, the way the SQL Optimizer is working.
..
1. Read the general information on searching for errors.
Concepts of the Database System, Troubleshooting
2. You can specifically analyze the SQL statements. You use the EXPLAIN statement, for example, to find out which search strategy the SQL Optimizer is using for the SQL statements.
3. Check your database design.
Concepts of the Database System, Database Design
See also:
SQL Reference Manual, EXPLAIN Statement (explain_statement)