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 6203321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:53:45+00:00 2026-05-24T04:53:45+00:00

I have written a very complex database migration script in Groovy, that runs just

  • 0

I have written a very complex database migration script in Groovy, that runs just fine on my workstation but produces “Caught: java.lang.OutOfMemoryError: Java heap space” when run on the server’s JVM. JVM is stuck as is (limited resources as an intern), so I need to figure out another way to fix this besides increasing available memory.

The error strikes when some of the largest tables are accessed: a particularly large, but simple, join (200,000+ rows to 50,000+ rows). Is there another way I can approach such a join that will save me from the error?

Example of query:

target.query(""" 
    SELECT 
        a.*, b.neededColumn 
    FROM 
        bigTable a JOIN mediumTable b ON 
    a.stuff = b.stuff 
    ORDER BY stuff DESC 
""") { ResultSet rs ->
    ...
}
  • 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-05-24T04:53:45+00:00Added an answer on May 24, 2026 at 4:53 am

    Can you run the join in SQL on the database server?

    If not, you’re probably stuck with iterating through each of your 200,000 results joining it to the 50,000 rows and writing out the results (so you aren’t storing more than 1*50,000 results in memory at any one time)

    Or, if you have access to multiple machines, you could divide your 200,000 items into blocks and do one block per machine?

    Edit

    Taking your example code, you should be able to do:

    new File( 'output.csv' ).withWriter { w ->
      target.eachRow( '''SELECT a.a, a.b, a.c, b.neededColumn FROM
        bigTable a
        JOIN mediumTable b ON a.stuff = b.stuff
        ORDER BY stuff DESC''' ) { row ->
        w.write "$row.a,$row.b,$row.c,$row.neededColumn"
      }
    }
    

    That will write each row out to the file output.csv

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

Sidebar

Related Questions

I have written a very simple test application that creates a websocket and parses
I am getting data from my database and I want to have that data
With Rails 3.1, the sprockets gem was introduced. I have written a very large
I had issues with debugging some very complex integration test in our application. The
I am currently working on a complex web interface and backend, that will need
I've written a few complex MVC applications which are all role based and use
I have written this code which accesses the Delete method on Web Service x,
i have generated a cs-classes with the xsd-tool from some xml scheme. The scheme
i've got a webscript in alfresco which is written in javascript. In this webscript

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.