Maximum length of MySQL query?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bert Sierra

    Maximum length of MySQL query?

    Does anyone know if there's an upper limit to the length of the query
    string supplied to the mysql_query() function? It appears that strings
    themselves can go well beyond 65,536 characters: the PHP manual does not
    seem to specify the upper limit, but in one test I was able to construct
    a 1,000,960 character string without a hitch.

    The queries my code will construct will be considerable smaller --
    between 3,500 characters and roughly 20,000 characters. Can anyone tell
    me if a 20,000-character UPDATE will cause problems, given the code
    below and assuming that the $updateSQL string contains valid MySQL code:

    $database_VoIP_ Connection = ...;
    $VoIP_Connectio n = ...;
    $updateSQL = "UPDATE ... SET ... WHERE ...";
    mysql_select_db ($database_VoIP _Connection, $VoIP_Connectio n);
    $Result1 = mysql_query($up dateSQL, $VoIP_Connectio n) or
    die(mysql_error ());

    I can chop up the query into smaller pieces if need be, but I'd rather
    execute a single UPDATE for speed and simplicity.


    -- Bert Sierra
    Tempered MicroDesigns
    Prescott, AZ
  • py

    #2
    Re: Maximum length of MySQL query?

    Bert Sierra wrote:[color=blue]
    > Does anyone know if there's an upper limit to the length of the query
    > string supplied to the mysql_query() function? It appears that strings
    > themselves can go well beyond 65,536 characters: the PHP manual does not
    > seem to specify the upper limit, but in one test I was able to construct
    > a 1,000,960 character string without a hitch.
    >
    > The queries my code will construct will be considerable smaller --
    > between 3,500 characters and roughly 20,000 characters. Can anyone tell
    > me if a 20,000-character UPDATE will cause problems, given the code
    > below and assuming that the $updateSQL string contains valid MySQL code:
    >
    > $database_VoIP_ Connection = ...;
    > $VoIP_Connectio n = ...;
    > $updateSQL = "UPDATE ... SET ... WHERE ...";
    > mysql_select_db ($database_VoIP _Connection, $VoIP_Connectio n);
    > $Result1 = mysql_query($up dateSQL, $VoIP_Connectio n) or
    > die(mysql_error ());
    >
    > I can chop up the query into smaller pieces if need be, but I'd rather
    > execute a single UPDATE for speed and simplicity.
    >
    >
    > -- Bert Sierra
    > Tempered MicroDesigns
    > Prescott, AZ[/color]

    20,000-character should work fine with mysql > 4

    Look here for more info:
    Founded in 1997, DEVShed is the perfect place for web developers to learn, share their work, and build upon the ideas of others.


    py

    Comment

    Working...