kathas Posted September 2, 2007 Share Posted September 2, 2007 Hi to all, I have an issue... I will have a CSV file with the latest DB updates. I need to find the best practice for synchronizing my DB with the CSV using the least (execution time) queries possible. The current script, for each user in the CSV: Checks if he exists in the DB. If he exists it updates him, else it creates him. That means it executes two queries for each user in the CSV. I wonder how else can it be done... Btw the script runs ok and has an execution time of 21.1.... seconds for importing 1000 users in the DB. Regards, Kathas Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 2, 2007 Share Posted September 2, 2007 Have a look here: http://dev.mysql.com/doc/refman/5.0/en/load-data.html I recommend using that to read into a temp table and then using: INSERT ... SELECT from the temp table into your final tables. Quote Link to comment Share on other sites More sharing options...
kathas Posted September 2, 2007 Author Share Posted September 2, 2007 Wow thanks a ton roopurt!!! This must be a lot faster... i had no idea... I will implement it and post here again for the time difference --- Kathas Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.