Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP PDO API Calls

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #41140
    lexy21kw
    Participant

    * 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?*

    #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).

    #116236
    lexy21kw
    Participant

    Thanks for the comment. Its given me some thoughts

    #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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.