Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:12:33+00:00 2026-06-16T05:12:33+00:00

Let me first brief about the scenario. The database is Sybase. There are some

  • 0

Let me first brief about the scenario. The database is Sybase. There are some 2-3 k stored procedures. Stored procedures might return huge data (around million records). There will be a service (servlet / spring controller) which will call the required procedure and flush the data back to client in xml format.

I need to appy filtering (on multiple column & multiple condition) / sort (based on some dynamic criteria), this I have done.

The issue is, as the data is huge, doing all the filtering / sorting in-memory is not good. I have thought of below options.

Option 1:
Once I get the ResultSet object, read some X no. of records, filter it, store it in some file, repeat this process till all the data is read. Then just read the file and flush the data to client.

I need to figure out how do I sort the data in file and how to store objects in file so that the filtering/sorting is fast.

Option 2:
Look for some Java API, which takes the data, filters it & sort it based on the given criteria and returns it back as a stream

Option 3:
Use in-memory database like hsqldb, h2database, But I think this will overhead instead of helping. I will need to insert data first and then query data and this will also in turn use the file system.

Note I don’t want to modify the stored procedures so the option of doing filtering/sorting in database is not an option or might be the last option if nothing else works.

Also if it helps, every record that I read from ResultSet, I store it in a Map, with keys being the column name and this Map is stored in a List, on which I apply the filtering & sorting.

Which option do you think will be good for memory footprint, scalable, performance wise or any other option which will be good for this scenario ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:12:38+00:00Added an answer on June 16, 2026 at 5:12 am

    I would recommend your Option 3 but it doesn’t need to be an in-memory database; you could use a proper database instead. Any other option would be just a more specific solution to the general problem of sorting huge amounts of data. That is, after all, exactly what a database is for and it does it very well.

    If you really believe your Option 3 is not a good solution then you could implement a sort/merge solution. Gather your Maps as you already do but whenever you reach a limit of records (say 10,000 perhaps) sort them, write them to disk and clear them down from memory.

    Once your data is complete you can now open all files you wrote and perform a merge on them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First let me start by explaining my use case: Say there is a database
Let me first tender my apologies for my question might be too long to
Let me brief you the whole requirement first. I have the following HTML code:
Let me first explain what I'm trying to achieve using some pseudo-code (JavaScript). //
Let me first stress the fact that I'm talking about the Mac OS X
My first question here so let's be brief. I am parsing this site: http://78.133.214.226/fotoweb/Grid.fwx
Let's first get to an important note about my situation: I have 1 table
First let me explain the data flow I need Client connects and registers with
Let me first state that I know next to nothing about LDAP and this
Let me first describe the picture below: There are two printed papers. The only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.