SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what are buffered queries ?

    hiya..

    an someone explan what are the buffered and unbuffered queries ?

    thanks

  2. #2
    Non-Member
    Join Date
    Dec 2006
    Posts
    269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by janu View Post
    hiya..

    an someone explan what are the buffered and unbuffered queries ?

    thanks
    I would have to know more about the DMBS you are using to give you an exact answer, but in general, a buffered query is one where the SQL query is already parsed out, optimized, and compiled into cached in memory so that it can be quickly executed. This is important in high transaction systems. Unbuffered queries, would have to be have to go through each of these steps, each time the query is executed. This usually happens in an ad-hoc query environment.

    Hope this helps,
    Rich

  3. #3
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    sorry rich, that's wrong.

    a buffered query is where the client waits for the complete result set to be returned before continuing. an unbuffered query returns after the query is compiled and begins execution, but before any rows are returned. the client will only wait when it asks for a row and one is not already in the client's memory but mysql has not finished executing the query.

    in practical terms, this means that when using an unbuffered query certain information is not available, such as the number of rows returned, and you can't seek back and forth through the result set. but using an unbuffered query makes sense when you're processing huge numbers of rows because your memory requirements can be lower and your application takes less time overall.

    here's an example:
    PHP Code:
    $res mysql_query($sql); //buffered query waits for all rows here

    while ($row mysql_fetch_assoc($res)) { //unbuffered query waits for next row here
      // do stuff


  4. #4
    Non-Member
    Join Date
    Dec 2006
    Posts
    269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by longneck View Post
    sorry rich, that's wrong.

    a buffered query is where the client waits for the complete result set to be returned before continuing. an unbuffered query returns after the query is compiled and begins execution, but before any rows are returned. the client will only wait when it asks for a row and one is not already in the client's memory but mysql has not finished executing the query.

    in practical terms, this means that when using an unbuffered query certain information is not available, such as the number of rows returned, and you can't seek back and forth through the result set. but using an unbuffered query makes sense when you're processing huge numbers of rows because your memory requirements can be lower and your application takes less time overall.

    here's an example:
    PHP Code:
    $res mysql_query($sql); //buffered query waits for all rows here

    while ($row mysql_fetch_assoc($res)) { //unbuffered query waits for next row here
      // do stuff

    Thanks for the info. From my experiences, this was referred to as result set processing, but it appears that MySQL has specific nomenclature for this type of processing.

    Rich

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mate, that really helps..

    thanks thanks...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •