Total rows: ' . mysqli_num_rows(mysqli_query($con, "SELECT * FROM floats;")) . '
Selecting rows within 50 miles of Seattle...
Test |
Time taken |
Query |
Results |
';
flush();
test(
$con,
'floats : procedure',
"CALL float_coords_within_radius(47.6, -122.33, 50);" // Within 50 miles of Seattle
);
test(
$con,
'floats_indexed : procedure',
"CALL float_indexed_coords_within_radius(47.6, -122.33, 50);" // Within 50 miles of Seattle
);
test(
$con,
'floats : function',
"SELECT * FROM floats WHERE haversine(lat, lon, 47.6, -122.33) < 50;", // Within 50 miles of Seattle
false // disabled
);
test(
$con,
'floats_indexed : function',
"SELECT * FROM floats_indexed WHERE haversine(lat, lon, 47.6, -122.33) < 50;", // Within 50 miles of Seattle
false // disabled
);
test(
$con,
'floats : inlined',
"SELECT * FROM floats WHERE acos(
cos(radians(lat)) *
cos(radians(47.6)) *
cos(radians(lon) - radians(-122.33)) +
sin(radians(lat)) *
sin(radians(47.6))
) * 3959 < 50;" // Within 50 miles of Seattle
);
test(
$con,
'floats_indexed : inlined',
"SELECT * FROM floats_indexed WHERE acos(
cos(radians(lat)) *
cos(radians(47.6)) *
cos(radians(lon) - radians(-122.33)) +
sin(radians(lat)) *
sin(radians(47.6))
) * 3959 < 50;" // Within 50 miles of Seattle
);
{
// $results = [];
// $start = microtime(true);
// $result = mysqli_query($con, "SELECT * FROM floats;");
// while ($row = mysqli_fetch_assoc($result)) {
// if (haversine($row['lat'], $row['lon'], 47.6, -122.33) < 50) { // Within 50 miles of Seattle
// $results[] = $row;
// }
// }
// $end = microtime(true);
// row('floats : php', $end - $start, 'SELECT * FROM floats;', count($results));
row('floats : php', 'disabled', 'SELECT * FROM floats;', 0, true);
}
test(
$con,
'hybrid : procedure',
'CALL hybrid_coords_within_radius(47.6, -122.33, 80467);' // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'hybrid_point : procedure',
'CALL hybrid_coords_within_radius_point(POINT(-122.33, 47.6), 80467);' // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'hybrid_indexed : procedure',
'CALL hybrid_indexed_coords_within_radius(47.6, -122.33, 80467);' // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'hybrid_indexed_point : procedure',
'CALL hybrid_indexed_coords_within_radius_point(POINT(-122.33, 47.6), 80467);' // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'hybrid : inlined',
"SELECT * FROM floats WHERE ST_DISTANCE_SPHERE(POINT(-122.33, 47.6), POINT(lon, lat)) < 80467;", // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'hybrid_indexed : inlined',
"SELECT * FROM floats_indexed WHERE ST_DISTANCE_SPHERE(POINT(-122.33, 47.6), POINT(lon, lat)) < 80467;" // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'points : procedure',
"CALL point_coords_within_radius(POINT(-122.33, 47.6), 80467);" // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'points_indexed : procedure',
"CALL point_indexed_coords_within_radius(POINT(-122.33, 47.6), 80467);" // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'points : inlined',
"SELECT * FROM points WHERE ST_DISTANCE_SPHERE(POINT(-122.33, 47.6), coord) < 80467;" // Within 80,467 meters (50 miles) of Seattle
);
test(
$con,
'points_indexed : inlined',
"SELECT * FROM points_indexed WHERE ST_DISTANCE_SPHERE(POINT(-122.33, 47.6), coord) < 80467;" // Within 80,467 meters (50 miles) of Seattle
);
print '