This content has been marked as final. Show 3 replies
To begin with, what do you do now in your code when you generate a ResultSet? You should be turning each row into an appropriate business object, and putting all these rows into an appropriate row collection class. Since you are doing that, why not add the functionality you need to your row collection class?
Hacland wrote:Sorry to nag about this, but I'm not sure I understood this. What exactly do you mean by "for reasons of DB overhead"? Do you want to reduce the load on your Database server? Or what else?
I know that the obvious answer to this question is to be more detailed in the original SQL statement. However for reasons of DB overhead I want to return the ResultSet and then iterate over it to separate out all relevant data.
Are you aware that actually passing your requirements to the DB might reduce the load it takes for the DB to process your query? It could use a Index instead of a full table scan and having to send less data definitely reduces the load on the DB service. Basically the more information you give the DB the more possibilities it has to optimize your query. If you simply tell it "give me the content of table A" then it really can't do anything smart. If you tell it "give me every column in A where c1 = foo and c2 = bar" then it can use indices and other smart techniques.
What you are trying to do is treat the DB as a dumb datastore and do the data filtering in your program and that's exactly the wrong way.
I know that the obvious answer to this question is to be more detailed in the original SQL statement. However for reasons of DB overhead I want to return the ResultSet and then iterate over it to separate out all relevant data.neophyte thinking.
the database is optimized to do that much faster than you ever will. write the query so the database does the work and bring it back.