A large mount of co-current queries
Moderator: General Moderators
A large mount of co-current queries
Hi guys,
I have written a PHP script that performsaround 10 queries.
And tested it intensively with a few client at the moment for along time and it loaded the database and caused a very long query time.
How can I prevent it? Should I lock and unlock the table in the beginning and the end of the PHP script?
Thanks!
I have written a PHP script that performsaround 10 queries.
And tested it intensively with a few client at the moment for along time and it loaded the database and caused a very long query time.
How can I prevent it? Should I lock and unlock the table in the beginning and the end of the PHP script?
Thanks!
Re: A large mount of co-current queries
10 queries isn't very much at all. I've got scripts that do thousands of queries that are fine. I think there's a bigger problem somewhere.
Re: A large mount of co-current queries
What are the queries doing?
Re: A large mount of co-current queries
The update / insert to the table or just select.
Re: A large mount of co-current queries
If there aren't any joins then it can't be slow at all with 10 queries, unless your server is a heap of junk.
Re: A large mount of co-current queries
I made a stress test. 6 clients that call a PHP script every a few seonds.
The PHP makes about 10 queries. It started fine, but as the time passed it became slower and slower...
The PHP makes about 10 queries. It started fine, but as the time passed it became slower and slower...
Re: A large mount of co-current queries
Try using this code with various queries to see if there is a bottleneck.
Re: A large mount of co-current queries
Could be running out of memory. Do the queries select massive resultsets?amiramir wrote:I made a stress test. 6 clients that call a PHP script every a few seonds.
The PHP makes about 10 queries. It started fine, but as the time passed it became slower and slower...
Re: A large mount of co-current queries
Most of the queries update or insert to the table.
The select finds a unique row.
The select finds a unique row.
Re: A large mount of co-current queries
Is it inserting loads of data? That can slow things down a lot.
Re: A large mount of co-current queries
Around 10 rows per script execution.
Re: A large mount of co-current queries
Well, be the sounds of it the script should run fine with loads of concurrent users. There's something seriously wrong with the code if it isn't working properly.
Re: A large mount of co-current queries
Thank you guys for your help.
It seems that I created a huge load on the server. This server is my web host, and is not capable of dealing with a big amount of queries.
I'll start my project as a pilot mode, and when time comes, I will find a databse hosting service for that purpose.
Thanks again
It seems that I created a huge load on the server. This server is my web host, and is not capable of dealing with a big amount of queries.
I'll start my project as a pilot mode, and when time comes, I will find a databse hosting service for that purpose.
Thanks again
Re: A large mount of co-current queries
10 queries is not a lot.
As onion2k said, scripts can execute thousands in under a second.
Sounds like you need new hosts, or they need to upgrade their hardware.
As onion2k said, scripts can execute thousands in under a second.
Sounds like you need new hosts, or they need to upgrade their hardware.
Re: A large mount of co-current queries
When I look in phpmyadmin stats it constantly handles thousands of queries per second, so there is something wrong with your queries. Show us them. On the crappiest machine it should not be noticeably slow.
Show us your code.
Are you inserting pictures? Are your tables HUGE? Indexed properly?
Show us your code.
Are you inserting pictures? Are your tables HUGE? Indexed properly?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.