Unanswered: mysql - client vs. .mysql_query execution time .
mysql - client vs. .mysql_query execution time ..
The query used is below:
$sql_query="SELECT doc_plata.data,doc_plata.data_efectiva,doc_plata.i d,doc_plata.nr,doc_plata.nr_document,doc_plata.id_ rol,contribuabil.nume,contribuabil.prenume,contrib uabil.cnp,doc_plata.suma,doc_plata.activ FROM (doc_plata LEFT JOIN borderou ON doc_plata.id_borderou=borderou.id) INNER JOIN contribuabil ON doc_plata.id_contribuabil=contribuabil.id WHERE doc_plata.id_borderou='$this->id_borderou' AND doc_plata.id_mod_plata='$this->id_mod_plata' AND borderou.id_casier='$this->id_casier' ORDER BY data_efectiva";
Execution time in mysqlclient :
280 rows in set (0.21 sec)
Execution time in mysql_query .php script:
Document: Done (31 secs !!!! - I can eat a sandwich in between ..)
I tried the query directly to the machine where php-mysql is installed (so It's not about network load)
It blows me away ( I need all records in one page - can't use LIMIT 0,x)
Let's see the script. There could be an isue there. Have you considered timing portions of the script? Also, are you making straight calls to the db (mysql_query() for example) or using an abstraction layer? If so, what is it? Be mindfull: dbx is around 50 to 55% percent slower during the query phase.
You mention that a dbx (you mean a db extraction layer, right?) is slower by 50% or more. I am curious, how do you know this? As well, we shouldn't try to mislead the author of this post. If the dbx is slower it certainly would not slow down their script to 31 sec. I personally find using a dbx much more straightforward and it keeps my code much more clean. Just curious, why do you think people use them? Is it for portability?
As you can see, the author of the site found that particular extension to slower than just straight MySQL calls (as an example) too. This was suprising to both of us as dbx is a engine level abstraction layer. It's written in C, not PHP.
Originally posted by piet
As well, we shouldn't try to mislead the author of this post. If the dbx is slower it certainly would not slow down their script to 31 sec.
No effort to mislead. Just trying to bring up some points and things to be aware of that could be part of the problem. An abstraction layer is ALLWAYS going to add overhead and allmost always will result in a increase in execution time. This is a constant. That said, how much overhead or slowdown occurs is a question of how well the abstraction layer is written.
Originally posted by piet
I personally find using a dbx much more straightforward and it keeps my code much more clean. Just curious, why do you think people use them? Is it for portability?
The truth about the above is that you wouldn't have asked if you knew what the dbx extensions are.
I know what abstraction layers are and use and have used. On one of my sites, I use the Eclipse Library (this is still PHP) . I also have one of my own called Small Unit Raid which is based on the idea of using something akin to structures in C.