Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. SELECT
  2. MAX_STATEMENT_TIME = 1000 --in milliseconds
  3. *
  4. FROM table;
  5.  
  6. <?php
  7.  
  8. //make it real slow lol...
  9. $sql = "
  10. select *
  11. from information_schema.tables t1
  12. join information_schema.tables t2
  13. join information_schema.tables t3
  14. join information_schema.tables t4
  15. join information_schema.tables t5
  16. join information_schema.tables t6
  17. join information_schema.tables t7
  18. join information_schema.tables t8
  19. ";
  20.  
  21. $mysqli = mysqli_connect('localhost', 'root', '');
  22. $mysqli->query($sql, MYSQLI_ASYNC | MYSQLI_USE_RESULT);
  23. $links = $errors = $reject = [];
  24. $links[] = $mysqli;
  25.  
  26. // wait up to 1.5 seconds
  27. $seconds = 1;
  28. $microseconds = 500000;
  29.  
  30. $timeStart = microtime(true);
  31.  
  32. if (mysqli_poll($links, $errors, $reject, $seconds, $microseconds) > 0) {
  33. echo "query finished executing. now we start fetching the data rows over the network...n";
  34. $result = $mysqli->reap_async_query();
  35. if ($result) {
  36. while ($row = $result->fetch_row()) {
  37. // print_r($row);
  38. if (microtime(true) - $timeStart > 1.5) {
  39. // we exceeded our time limit in the middle of fetching our result set.
  40. echo "timed out while fetching resultsn";
  41. var_dump($mysqli->close());
  42. break;
  43. }
  44. }
  45. }
  46. } else {
  47. echo "timed out while waiting for query to executen";
  48. var_dump($mysqli->close());
  49. }
  50.  
  51. select * from tbl_with_1billion_rows
  52.  
  53. select sum(foo) from tbl_with_1billion_rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement