Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to improve doctrine performance (plain sql is 4x faster)?

Tags:

php

doctrine

The problem is next - I want to execute simple query (e.g. 10 rows from one table)

In Doctrine this operation takes 0.013752s

Here is DQL:

$q = Doctrine_Query::create()
    ->update('TABLE')
    ->set('FIELD', 1)
    ->where('ID = ?', $id);
$rows = $q->execute();

But when i use plain sql and mysql_query() it takes only 0.003298s

What's wrong? Is Doctrine realy 4x slower?

like image 850
John W. Avatar asked Nov 28 '25 11:11

John W.


1 Answers

John,

Nothing is wrong. Doctrine introduces considerable overhead compared to a straight SQL query. But you gain the convenience of a nice object oriented interface to the database as well as many other benefits. If raw performance is really important then you might not want to use Doctrine. For queries where I need performance over convenience (hundreds of thousands of inserts for example) I use PDO to avoid the overhead that gets introduced by the ORM.

like image 60
Henning Glatter-Götz Avatar answered Dec 01 '25 03:12

Henning Glatter-Götz