Slow MYSQL Inserts?



I’ve been doing some backend debugging of the members area since a few of the recent purchases have been processed incorrectly and have found that SQL inserts into my user table seem to be delayed.  My PHP continues BEFORE the insert seems to complete.  No, I’m not using “INSERT DELAYED”.

For example (note, this isn’t my DB setup, it’s just an example):

$query = "INSERT INTO users ( `ID` , `email` , `password`) VALUES ( '10', 'myemail@email.com', '12345')";
mysql_query ($query) or die ('Could not create user.');
$query = "SELECT id FROM users WHERE email = 'myemail@email.com'";
$result = mysql_query($query);

This should give me a result set consisting of the 10…instead it gives me nothing.  In debugging, both queries work, so it’s not a syntax error.  And viewing the table after the fact, the record appears correct.  As a workaround, I currently close the database connect between the two mysql_query()…but that seems like a
silly thing to need to do.

Any thoughts?




2 Responses to “Slow MYSQL Inserts?”

  1. Luigi

    In your example, it should be
    SELECT ID not id

    May 5th, 2008 at 6:30 am
     
  2. kansieo

    Actually, it was the other way around…lowercase. Still, not sure if that was the culprit or not. Thanks for pointing that out!

    May 7th, 2008 at 11:06 am
     

Leave a Reply