Lasha Kitia
Lasha Kitia

Reputation: 141

Doctrine slows down performance

Application: Symfony3.4

ORM: Doctrine2

(I also can give you web server configuration)

I have performance problem caused by doctrinei.stack.imgur.com/7B024.png

Query execution time is 1685.69 ms i.stack.imgur.com/VBEJt.png

Then I've run the same query through MySQL console and got different performance result (115 ms) i.stack.imgur.com/1lNgv.png

Any guesses?

Upvotes: 0

Views: 1601

Answers (2)

Lasha Kitia
Lasha Kitia

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

Frederik Banke
Frederik Banke

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

Related Questions