klaasa klaasa - 4 months ago 10
SQL Question

PHP Mysql query gets extremely slow after adding another WHERE parameter

I have been googling for a while about this issue, but couldn't find a solution.
I have a

query
that is gathering information from a
mysql
database
and whenever I had this to the query:
"date = {$this->datum->format('Y-m-d')}"
it takes around 5 seconds to finish. When I don't use this
parameter
it is just taking a few milli seconds.

Anyone knows what is causing this
issue
?

Answer

Try adding an index :

CREATE INDEX index_name
 ON table_name (`date`)