I guess no one will have a definative answer to this but considered predictions would be appriciated.
I am in the process of developing a mySQL database for a web application and my question is:
Is it more efficient to make a single query that returns a single row using AJAX
or
To request 100 – 700 rows when the user will likely only ever use the results of two or three?
Really I am asking what is heavier for the server 2-3 requests with one result or 1 request with 100 – 700 results?
Thanks,
Mark
You may want to time how long it takes to get the data from the database. If it takes too long, which will need to be determined by you, but I would guess is over 10 seconds, then you may want to break it into smaller requests, but 700 would be much. You could determine how long you want it to take, but you may want to try to get it to take less than 1 second for each request, and see how many requests that will take.
Profiling is important, as the database may not be the problem. If you are building a large table, for example, with 1000 rows, then if you fully create the table then render it, that will take a while.
Your best bet is to use firebug, in firefox, and see how long it actually took to get the data, since you have already profiled how long the database connection actually takes, and then you can see how long it seems to take to display the data once the information returned from the server.
Profiling is your best bet, as firebug allows you to profile javascript, to see if you really need to optimize the database.