mysql_query takes long time...
| From: | דניאל דנון | Date: | Sun, 31 May 2009 12:18:26 +0000 |
| Subject: | mysql_query takes long time... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-293398@lists.php.net to get a copy of this message | ||
I've a file of about 500,000 lines, each line contains a string in variety
of lengths, but no less then 3 characters and usually no more then.... 120.
average of about 80, and maximum of about 250.
I made a PHP script to fetch the data (using fgets), process it and insert
it to a MySQL database.
The problem is inserting to MySQL takes about 0.02 seconds, which looks like
nothing - but when you have 500,000 lines to insert...
The while goes like that:
fgets from file
x1 = some function about the string
x2 = some other function about the string
x3 = the string
insert into table (field1, field2, field3) VALUES (x1, x2, x3)
(pseudo-code)
I was wondering, is there any faster way to perform it, assuming I have to
do it with PHP?
also, if it matters - the MySQL table got id in auto increment.
Yours, Daniel.
--
Use ROT26 for best security