MySQL timing out when selecting one record out of 9 million

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fishnfrogs
    New Member
    • Nov 2009
    • 20

    MySQL timing out when selecting one record out of 9 million

    Hi, I just uploaded 9 million records to a mysql table. The table consists of an id, a name, and a numeric value. The way its supposed to work is that the user passes the name to php and php returns the numeric value. However, either mysql or php is timing out -- I think. Here's what I've got so far:

    Code:
    $query = "SELECT `value` FROM `table` WHERE `name` = '$q' LIMIT 1";
    
    $result = mysql_query($query) or die(mysql_error());
    
    mysql_close($dbhandle);
    
    if($result)
    {
    	if(!$row = mysql_fetch_array($result))
    	{
    		//STILL SHOWS UP HERE
    		//no value
    	}
    	else
    	{
    		//value
    	}
    }
    else
    {
    
    	//no value
    }
    When the query is called and times out, mysql still returns an empty row. Is there anyway to optimize the query or anything else I can do to retrieve the records? Thanks in advanced!
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Sorry, just to make sure: Have you been able to retrieve any other records from this table with a more defined search? If there are 9 million records you may need to give it more time to search.

    Comment

    • fishnfrogs
      New Member
      • Nov 2009
      • 20

      #3
      Hi, yeah, I've been able to load other records. It seems to be fine loading the records with a higher index. When I try to load the first row, I get the problem of the empty result. In my file, I have code that will fire when the empty row is returned, so I know that's where my issues are.

      Comment

      Working...