PHP takes 90x longer to run query than MySQL client

前端 未结 4 613
轻奢々
轻奢々 2020-12-10 02:46

I\'m running a MySQL query via a command-line PHP script (prepared query using PDO on the mysqlnd driver). It\'s a simple query with a single left-join, returning 100 rows

4条回答
  •  北海茫月
    2020-12-10 03:05

    I had the same problem. Same query was acting differently when launched from cli and from PHP. Explain in cli mentioned correct index usage, in PHP there was nothing. As I have found, the problem was type casting, in my case it was datetime. After I have specifically cast type for compared value eg. where datetime_column > cast('2014-01-12 12:30:01' as datetime) everything works.

提交回复
热议问题