Can you describe the data in the table? I can think of a few solutions, most if which are based on the data you are storing. For example, chances are when you have large tables you are probably not doing any summarization of your data. If possible pre-compute the result and spit out the answer ...