Welcome Guest, Not a member yet? Register   Sign In
CSV Importing Advice
#6

(04-25-2017, 12:46 PM)kilishan Wrote: The problem looks like you're doing several db interactions at each point during this loop. You're checking to see if the company exists, potentially inserting a new department and updating the user to show they belong to that department. That many db interactions is going to cause a slowdown.

The best thing you can do is to break that down into a few individual steps to minimize the number of times you hit the db. It might mean looping over the CSV and collecting different arrays of info, like users, departments, whatever. Then you could pull all departments in one query. You could collect the department/user correlations and perform a single insert_batch. Things like that.

You're right. I always felt that doing a db interaction for each line wasn't the right choice. I will have to have a good think about how to improve it. Thanks.
Reply


Messages In This Thread
CSV Importing Advice - by keithmclaughlin - 04-25-2017, 09:26 AM
RE: CSV Importing Advice - by skunkbad - 04-25-2017, 11:25 AM
RE: CSV Importing Advice - by keithmclaughlin - 04-25-2017, 11:33 AM
RE: CSV Importing Advice - by kilishan - 04-25-2017, 12:46 PM
RE: CSV Importing Advice - by keithmclaughlin - 04-26-2017, 03:06 AM
RE: CSV Importing Advice - by marksman - 04-25-2017, 04:57 PM
RE: CSV Importing Advice - by keithmclaughlin - 04-26-2017, 03:06 AM
RE: CSV Importing Advice - by marksman - 04-26-2017, 02:16 PM
RE: CSV Importing Advice - by qury - 04-26-2017, 12:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB