So my situation is the following. I obtain data from a certain source through PHP every 24 hours. Now during that time this data gets changed, new data is added or some is updated. Now when I run a query to insert or update this data each 24 hours it takes a long time for the query to execute. This would not be a problem if the execution time was moderate as I am planning on making this a cron job, however the execution time now is way too high.
So I was thinking about writing this data from PHP to a CSV file, when I obtain it. And then using this CSV file together with the MySQL LOAD DATA
function which supposedly inserts a lot of data from a file in a very quick manner.
So the question is it possible to write to a CSV file from PHP and have it formatted in a way that suits the LOAD DATA INFILE
function, and how can I each 24 hours delete that CSV and create a new one with newly inserted data, and how would I go about properly using the LOAD DATA INFILE
function with this particular CSV file? Oh and can I make a cron job out of all of this ? Thanks.