I have 2 tables - info and comments. info has 270,000 rows, while comments has only 100 rows.
I run a php script that selects the data from the database and encodes it to json format. The PHP script also limits the response to only first 10 rows, and both PHP files Info.php and Comments.php are exactly the same, except the names.
So why is it, that the table with 270,000 rows takes way more time to load than the one with 100 rows when it only prints the first 10 rows? comments takes 1 seconds while info takes 10 seconds.
This is the PHP query code, pretty simple :
Info.php: $query = "SELECT * FROM info ORDER BY id LIMIT 10;";
Comments.php: $query = "SELECT * FROM comments ORDER BY id LIMIT 10;";
As for testing purposes, they both have the same columns and same data, the only difference is the rows number. So I tested times with PHP and:
Info.php:
select from database time: 0.6090 seconds
time taken to decode JSON: 6.4736 seconds
while Comments.php results:
select from database time: 0.7309 seconds
time taken to decode JSON: 1.7178 seconds
Thanks