<?
//Connect to Database
$link = mysql_connect("localhost","******","*********") or
die ("Could not connect to database");
mysql_select_db("pickasite") or
die ("Could not select database");
//Update A Counter of how many times we've done this
$randomhits = mysql_query("SELECT `randomhits` FROM `stats`",$link);
$row = mysql_fetch_row($randomhits);
$randomhits = ((integer)$row[0])+1;
mysql_query("update `stats` set randomhits=$randomhits",$link);
//Seed a random number machine
mt_srand((double) microtime()*1000000);
//Number of total items in this table
$bignumber = mysql_query("select count(*) from urldatabase", $link);
$myrow = mysql_fetch_row($bignumber);
$myRandom = mt_rand(1,$myrow[0]);
//Select an item out of urldatabase at random, between the begining and end of the table.
$myURL = mysql_query("select url from urldatabase limit $myRandom, 1", $link);
$myresult = mysql_fetch_row($myURL);
$actualaddres = stripslashes($myresult[0]);
//The End
mysql_close($link);
?>
Here's the main chunk of my code. It basically pulls an item from a database at random. The problem is, the table 'urldatabase' as a little over 4 million items in it, and is about 165 MB in size. It usually takes about 5 second or more to read the item out. So I'm wondering if there are any ways I can speed this up somehow, optimize it a bit? (besides faster hardware :-P )