Solved

MySQL PHP Query Delays

Posted on 2011-09-23
3
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

635 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