As has been said elsewhere, if your query is reused then you could have a performance boost. But your query must return the same results as well. If your dataset is not static, then you will have to redo the query anyway.
There are a lot of options to improve performance. If you have exhausted all of the options do with indexes, increasing hardware on the server, increasing the bandwidth of the network between your server and client(s), then you could explore some other options:
- cache the HTML for a request: note
that this will cache the results for
a search & the sort used; if the user
changes the order of one of the
columns, then you'll need to redo the
query (*)
- cache the id's of the search, but not
the order by. More complex to handle,
but has the benefit that if the user
changes the column order, the query is still as fast. You can even pre-cache some common queries
As always, the performance of your system depends upon a lot of factors. To really answer your question you need to measure the performance on your system. If you have a doubt, measure. I've found a few times that the performance gain is negligable.
You also have to take into account the complexity you're adding to the system by performance optmizations like this, and the flushing of the cache, what happens if data changes, how do you handle all of these problems.