Running Amazingly Slow Of PHP Queries Against MySQL

This is a discussion on Running Amazingly Slow Of PHP Queries Against MySQL within the MySQL Database forums, part of the Database Forums category; I'm facing a bizare problem with my LAMP. For I'm preparing the webserver for one event, I have ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-05-2007
DarkPilgrim@gmail.com
 
Posts: n/a
Default Running Amazingly Slow Of PHP Queries Against MySQL

I'm facing a bizare problem with my LAMP.

For I'm preparing the webserver for one event, I have some simple
tests on the server.
I write a php script in which I run about 3000 queries against mysql
db(loop the same query for 3000 times). The queries are simple, just
select * from some table(this table only has about 100,000 records).
But this script told me it cost about 85 seconds!! I have set Apache,
MySQL and PHP on my own machine where the same script cost less than 1
second.
I can't find any error in php or mysql logs.
Server: Red Hat AS 5, Apache 2.2.3, PHP 5.1.6, MySQL 5.0.22 (these are
buddled with red hat)

Anyone, please help me.

Reply With Quote
  #2 (permalink)  
Old 11-05-2007
DarkPilgrim@gmail.com
 
Posts: n/a
Default Re: Running Amazingly Slow Of PHP Queries Against MySQL

On 11 5 , 11 36 , "DarkPilg...@gmail.com" <DarkPilg...@gmail.com>
wrote:
> I'm facing a bizare problem with my LAMP.
>
> For I'm preparing the webserver for one event, I have some simple
> tests on the server.
> I write a php script in which I run about 3000 queries against mysql
> db(loop the same query for 3000 times). The queries are simple, just
> select * from some table(this table only has about 100,000 records).
> But this script told me it cost about 85 seconds!! I have set Apache,
> MySQL and PHP on my own machine where the same script cost less than 1
> second.
> I can't find any error in php or mysql logs.
> Server: Red Hat AS 5, Apache 2.2.3, PHP 5.1.6, MySQL 5.0.22 (these are
> buddled with red hat)
>
> Anyone, please help me.


I do modified my.cnf but I think it should has no affect on this.
I changed back_log from 50 to 100, and max_connections from 100 to
3000m key_buffer_size to 256MB

Reply With Quote
  #3 (permalink)  
Old 11-05-2007
DarkPilgrim@gmail.com
 
Posts: n/a
Default Re: Running Amazingly Slow Of PHP Queries Against MySQL

On 11 5 , 11 36 , "DarkPilg...@gmail.com" <DarkPilg...@gmail.com>
wrote:
> I'm facing a bizare problem with my LAMP.
>
> For I'm preparing the webserver for one event, I have some simple
> tests on the server.
> I write a php script in which I run about 3000 queries against mysql
> db(loop the same query for 3000 times). The queries are simple, just
> select * from some table(this table only has about 100,000 records).
> But this script told me it cost about 85 seconds!! I have set Apache,
> MySQL and PHP on my own machine where the same script cost less than 1
> second.
> I can't find any error in php or mysql logs.
> Server: Red Hat AS 5, Apache 2.2.3, PHP 5.1.6, MySQL 5.0.22 (these are
> buddled with red hat)
>
> Anyone, please help me.


Now I don't know whether this is a problem. Because I run this on my
Virtual Machine(ubuntu 7.0.4 server). It costs about 80 seconds as
well. I fogot to say my own machine is Windows (Core 6300, 2GB
Kingston DDRII 667). The server is Pentium 820, 2GB Kinston DDR400.

Reply With Quote
  #4 (permalink)  
Old 11-05-2007
DarkPilgrim@gmail.com
 
Posts: n/a
Default Re: Running Amazingly Slow Of PHP Queries Against MySQL

I found the problem now. Ur...
I didn't enale query_cache(query_cache_size=0)
Ha.Anyway, I'm not familiar with MySQL configuration( fine tuning)

Reply With Quote
  #5 (permalink)  
Old 11-05-2007
Aaron Saray
 
Posts: n/a
Default Re: Running Amazingly Slow Of PHP Queries Against MySQL

On Nov 4, 10:58 pm, "DarkPilg...@gmail.com" <DarkPilg...@gmail.com>
wrote:
> I found the problem now. Ur...
> I didn't enale query_cache(query_cache_size=0)
> Ha.Anyway, I'm not familiar with MySQL configuration( fine tuning)


Good job figuring out your issue!

Hopefully a helpful reminder: If you're executing the same query 3000
times, you might benefit from using a prepared statement. You can
prepare the statement outside of the loop, and then loop through 3000
times binding new values and executing the statement.

Good luck. :)

Reply With Quote
  #6 (permalink)  
Old 11-09-2007
DarkPilgrim@gmail.com
 
Posts: n/a
Default Re: Running Amazingly Slow Of PHP Queries Against MySQL

On 11 5 , 4 38 , Aaron Saray <102degr...@102degrees.com> wrote:
> On Nov 4, 10:58 pm, "DarkPilg...@gmail.com" <DarkPilg...@gmail.com>
> wrote:
>
> > I found the problem now. Ur...
> > I didn't enale query_cache(query_cache_size=0)
> > Ha.Anyway, I'm not familiar with MySQL configuration( fine tuning)

>
> Good job figuring out your issue!
>
> Hopefully a helpful reminder: If you're executing the same query 3000
> times, you might benefit from using a prepared statement. You can
> prepare the statement outside of the loop, and then loop through 3000
> times binding new values and executing the statement.
>
> Good luck. :)


Thx for your reply and advice, Aaron Saray.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:32 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0