Skip to content

Instantly share code, notes, and snippets.

@ElliottLandsborough
Created October 2, 2019 14:52
Show Gist options
  • Save ElliottLandsborough/bb40db08e876a12864ee8f62840fe77c to your computer and use it in GitHub Desktop.
Save ElliottLandsborough/bb40db08e876a12864ee8f62840fe77c to your computer and use it in GitHub Desktop.
mysql.wat
// chooses a set of random ids. This set does not contain a fixed number of elements but they are around 20
$params = ['n' => $num_records, 'c' => $count, 'dc' => ($count * 2 < 20) ? 20 : $count * 2];
$results = DB::connection('mysql.huge_table')->select('SELECT id FROM atoms_in_universe WHERE RAND() * :n < :dc ORDER BY RAND() LIMIT 0,:c', $params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment