If the database system is taking too long to execute an SQL statement, analyze your database and, if necessary, the way SQL Optimizer is working.
Read the general information on troubleshooting.
More information: Database Administration, Troubleshooting, Analyzing Database Performance
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.
More information: EXPLAIN Statement
Check your data model.
SQL Reference Manual, EXPLAIN Statement (explain_statement)