- This topic is empty.
December 3, 2012 at 7:30 pm #41140lexy21kwParticipant
* How would I determine how much time is being spent in each PDO API call? I am aware of differentiating the amount DB execution time from the amount of time in each API call. (Interested in another other option)
* How would this solution impact the maintainability of my application? Specifically, if a new framework is added to the application how would this solution time PDO calls in the framework?
* In what ways could this solution change the performance characteristics of my application?*December 3, 2012 at 10:25 pm #116228__Participant
$start = microtime( true );
/* do PDO stuff
* (it will likely be necessary to perform
* the same task repeatedly, in a loop,
* to get a meaningful time period).
$stop = microtime( true );
$execution_time = $stop – $start;
As for the rest of your post, I am unsure what your actual question is, so this may or may not apply:
The single most time-consuming portion of any database API, by *far*, is the part where it actually queries the database. The process of sending a query, waiting for a response, and receiving the result can be called a “round-trip.”
If you want to speed up your database-related code, simply rewrite your code to make as few round-trips as possible.
… never use multiple queries where one would do (e.g., INSERT multiple records with the same statement)
… use JOINs and MySQL functions (aggregate functions, etc.) to combine queries involving multiple tables
… use TRANSACTIONs and multi-step queries (this is the main reason I prefer MySQLi over PDO: transactions and multi-queries are much easier)
… don’t query the DB when you don’t have to (this may seem obvious, but I see it all the time).December 4, 2012 at 12:36 am #116236lexy21kwParticipant
Thanks for the comment. Its given me some thoughtsDecember 4, 2012 at 1:11 am #116237__Participant
As I said, I wasn’t very clear about what you were actually asking. Did this answer your question?
If not, please explain further, and I’ll do my best to answer.
- The forum ‘Back End’ is closed to new topics and replies.