I have this query
$sql = mysql_query("SELECT DISTINCT a, b FROM table ORDER BY RAND() DESC limit 15");
Which worked great when my table has only a couple of rows, now my table has thousands this makes my page load really slow.
I have tried
$s = mysql_query("SELECT id FROM table");
$z = mysql_num_rows($s);
$n = rand(1,$z);
$sql = mysql_query("SELECT DISTINCT a, b FROM table limit $n, 15");
Which makes it a bit faster but it gives me a random row, then another 14 straight after it rather than all 15 being from random places, is there a better way to do this?