MySQL Normalization stored procedure performance -


I wrote a hosting process in MySQL, which is currently in a table and "normal" means that For each value passed to the stored procedure, it checks whether the price is already in the table or not. If it is, then it stores the ID of that row in a variable. If the price is not in the table, then it enters the newly entered value ID, then the stored procedure takes the ID and inserts them in a table that is equal to the original de-certified table, but this table is completely normal And mainly consists of foreign keys

My problem with this design is that the stored procedure takes about 10ms or more, which is too long When you are trying to work through some 10 million records, my suspicion is that performance is to be done in a manner in which I am inspecting. I.e.

  INSERT (argument_from_sp) duplicate key update ID = LAST_INSERT_ID (ID) in tables (first_view) values; SET @TableAId = LAST_INSERT_ID ();  

"On duplicate key update" is a bit of a hack, due to the fact that I do not want to update anything on the duplicate key, but only the id value will return to the quarrel. If you remember this step, then you are trying to run the "SET ..." statement, then the LAST_INSERT_ID () function returns an incorrect value.

Does anyone know better way to do this? My SQL?

I have gone back and instead created a function to handle this case:

  set DEFINER = `` `` `` `` `` `` `` `` `` `` `` `` ` `` `` Id = '' '' 'Select value for values ​​excluded from imported where value = inValue; If Iid out, insert value (value) in value (inValue); SELECT LAST_INSERT_ID () I Out; end if; Return Out Id; END  

The stored procedure mentioned earlier is called these tasks instead of doing the incentive statements. According to performance, the above work is faster in my setup (using NDB table type) . Also, after the benchmarking of all parts of my application, I have found that the performance problems that were arising were only a minor part of overall performance constraints.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -