Reputation: 141
Application: Symfony3.4
ORM: Doctrine2
(I also can give you web server configuration)
I have performance problem caused by doctrine
Query execution time is 1685.69 ms
Then I've run the same query through MySQL console and got different performance result (115 ms)
Any guesses?
Upvotes: 0
Views: 1601
Reputation: 141
I just found out what caused difference.
I was using PHPStorm's database console.
I tried to run the query through terminal and got same (slow) result.
The hard part of the query was CASE
s in WHERE
statement.
I changed CASE
with IFNULL(p0_.updated_at, p0_.created_at)
(query was still heavy)
Finally tried next: WHERE p0_.created_at >= '2018-01-02 00:00:00' AND p0_.created_at <= '2018-01-02 23:59:59'
(and got result in about 100 ms)
I don't know what PHP Storm did, but That was weird.
Thank you for your attention @frederik-banke-sørensen !
Upvotes: 0
Reputation: 492
If you execute the same query, first from doctrine and then directly. Then the query cache will make the second query run very fast.
Upvotes: 2