Newbie PHP MySQL Performance Issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mb2442
Forum Newbie
Posts: 7
Joined: Mon Oct 06, 2008 7:17 am

Newbie PHP MySQL Performance Issue

Post by mb2442 »

I have written a PHP script which loads a text file into an empty MySQL database table. I have versions of the script which use INSERT INTO and LOAD DATA INFILE. This test is being run on a Dell PC with XP SP3, Intel Core 2 1.86GHz, and 2 GB RAM. The text file is a syslog containing 80,000 records of 31 fields each.

With either version of the script, the MySQL query process always takes about 40 minutes and the PCs processor utilization is never above 2%. Memory utilization is around 521 MB. Changing the process priority has no effect. Running the test on a different PC (same O/S, different model PC, comparable specs) also has no effect.

The query takes at least 10 times longer than it should. Can anyone suggest where to look to solve this performance issue?

Thank you VERY much for your assistance.
staar2
Forum Commoner
Posts: 83
Joined: Fri Apr 06, 2007 2:57 am

Re: Newbie PHP MySQL Performance Issue

Post by staar2 »

Seems like the bottle neck is file reading and inserting it into database. I hope you don't use the whole file reading into one variable and then make some tokens for database insert. Fastest way what i think would be read line and then insert to database. I am sure the problems hides in code. So if it's not long then post here. :roll:

I suppose you use prepared statements, PDO or mysqli
mb2442
Forum Newbie
Posts: 7
Joined: Mon Oct 06, 2008 7:17 am

Re: Newbie PHP MySQL Performance Issue

Post by mb2442 »

That gives me some focus for some research. I appreciate it very much.

Thanks.
mb2442
Forum Newbie
Posts: 7
Joined: Mon Oct 06, 2008 7:17 am

Re: Newbie PHP MySQL Performance Issue

Post by mb2442 »

(Let me work on the code a while then I'll post it if I can't work past this knot. Thanks!)
Post Reply