Hi!
>>>>> "Lopez" == Lopez David <E-r9374c <[EMAIL PROTECTED]>> writes: <cut> Lopez> If no row is returned, then the following happens: Lopez> 1) lock table ... Lopez> 2) select ... Lopez> 3) if no row is returned, Lopez> 4) insert ... Lopez> 5) use LAST_INSERT_ID() to get the value of the key Lopez> 6) else get the key-value pair Lopez> 7) unlock table Lopez> 8) put key-value pair in RAM hash Lopez> 9) insert row in main table (using new key-value pair) Why not instead do as follows: (This assumes you have an unique index on the thing you are selecting on) select ... if no row is returned, insert ... if insert works without a duplicate key error: use LAST_INSERT_ID() to get the value of the key else select to find the row some other thread inserted put key-value pair in RAM hash insert row in main table (using new key-value pair) <cut> Lopez> Hope that clears the insertion process on the hash tables. I'm Lopez> glad that if a connection is lost in steps 2-6, mysql would Lopez> automatically unlock the tables. That will satisfy the db Lopez> specification nicely. The architecture for our db came Lopez> from the optimization chapter in the manual. Thanks! If the connection dies on the client side, the server will notice it as once. The thing you will not notice if a client goes into an endless loop and will not release the connection to the MySQL server. I will add to our TODO to add to SHOW OPEN TABLES a list of threads that has locks on the table (or maybe a SHOW LOCKS command) to better cover this case in the future. Regards, Monty -- For technical support contracts, goto https://order.mysql.com/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mr. Michael Widenius <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, CTO /_/ /_/\_, /___/\___\_\___/ Helsinki, Finland <___/ www.mysql.com --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php