Solved

MySQL PHP Query Delays

Posted on 2011-09-23
3
315 Views
Last Modified: 2012-05-12
Hello,

I have a MySQL server running, serving a large amount of numeric data to a website written in PHP (running on the same physical server).

The site has been running fine for years, with no significant code changes to the primary functions.

The site is setup with a frame set, a left menu and a main body.

On occasion, when a link is clicked in the left that opens a specific report, the right page will simply go to white screen, and never load.  In my code, if the MySQL connection fails, it should report "Couldn't connect to MySQL".  This never happens.  

I go into MySQL admin, and I see several processes that are all locked.  All of these are various SELECT statements into my table, all of which are valid based on different reports that have been opened.

As the data was needed quickly, I performed a server reboot and everything was accessible again.

My question is, what steps can I take now to hopefully prevent this from happening again.  Worse case, what should I do next time this happens, as the data is needed quickly by the users, and I won't have long before I'll have to reboot.

Thanks for any input
0
Comment
Question by:compsol1993
3 Comments
 
LVL 11

Expert Comment

by:maeltar
ID: 36587365
I would suggest just restarting the mysql process rather than a full reboot..

However, that is not a fix, far from it, I would be inclined to suggest that you look at the web server first, as you said that you just had a blank page returned/served this would indicate that the server did not respond.

Check the error logs both for mysql and apache, and post if you can around the relative times the issue occured.
0
 
LVL 8

Accepted Solution

by:
wolfgang_93 earned 500 total points
ID: 36590150
It sounds like you have MyISAM tables. In MyISAM, table locking is primitive in that tables get fully locked even if a single row is fetched. Look at converting to InnoDB to get row-level locking and only rows locked that are being updated -- not entire tables.
0
 

Author Closing Comment

by:compsol1993
ID: 36599140
After posting, my research led me down the same road, and I ended up making the conversion this weekend.  Everything is working great now, thanks for the advice.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Creating and Managing Databases with phpMyAdmin in cPanel.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question