This is more of a design/architecture question though can easily find its way in code as well. When improving the performance of a Java application deployed on app server talking to database to retrieve records, what is the best methodology?
Improve performance on the database layer by tuning SQL, ORM, any other form of tuning OR at Java code chosing best collections based on data, tuning code etc.
For one real-life scenario I had a requirement to parse some data from a BLOB looking for some attributes.
One option was to get all of data from dB and iterate through list looking for specific attributes thereby filtering the records;
Other option is to limit the data from DB by using complex queries/Stored procs and building REG Ex using Oracle's functions on BLOB.
Would like to know some practical pointers from real-world problems. We are talking about Millions of rows here for data I am referring to. I did resort to filtering using DB layer but still have not tested well with very large datasets.
Edit:
The question is Simple: This app/module has a front-end and a back-end which talks to Oracle. Need to retrieve and filter data from a BLOB containing Java serialized object. What is more efficient?
Parsing BLOB with the RAW function and building Regular Expressions (which can fail due to changing data in BLOB) OR Get Data via JDBC (API builds on top of some persistence layer using hibernate) and then filter it in Java layer.
This is a real life problem with a working app. I even discussed with a DBA and was suggested to filter it in Java layer.
Reference Questions:
How can I avoid "raw variable length too long" errors in SQL Developer?