Skip to content
Advertisement

How to remove files after LOAD DATA INFILE?

I’m using the LOAD DATA INFILE solution to speed up big inserts, like outlined here: http://www.mysqlperformanceblog.com/2006/07/12/insert-into-select-performance-with-innodb-tables/.

It works brilliantly, and very fast. However, when I do the select, I create a file, which is then used by the LOAD DATA INFILE command. But after using this file, I don’t need it any more. Can I get rid of it with an additional query? Or can I make it temporary somehow?

I’m using it on my server, so the file stays on my server and doesn’t involve the client in any way. I’m using PHP in conjunction with MySQL, so the solution may also be in PHP.

Advertisement

Answer

As air4x wrote, if(file_exists($file)) { unlink($file); }

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement