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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:29:20+00:00 2026-05-13T11:29:20+00:00

I am trying to move from a mysql set to a postgres one, and

  • 0

I am trying to move from a mysql set to a postgres one, and one of the fields that I’m having trouble moving is a mysql LBLOB. I am trying to move it into a LargeObject type in postgres and I’m having some speed issues. I’m doing this in Java/Groovy and, frankly, the streaming business has me confused.

I’ve tried two approaches: Hold the LBLOB in memory and write it directly to the LO, and write the LBLOB to disk (it is a file after all) and then read the file back in to the LO.

The second approach is many many times faster, and I can’t figure out why because I think it is still entirely too slow.

Here is the first approach.

InputStream ins = rs.getBinaryStream(1);
def b
while ((b = ins.read()) > -1) {
    obj.write(b.toInteger().byteValue())
}

“ins” is a ByteArrayInputStream so I read that in (to an int) and then write it to “obj”, the LO. This takes about 7 minutes for a 1MB file. My gut tells me this should be more efficient than the second one, but it is not.

I’ll spare the code snippet for the write to file version but it is pretty basic. It reads from the db the same way, but then writes the output to a file on disk. Then I go read the file from disk and write it to the LO. That approach takes about 8 seconds for the same file.

What is going on?

  • 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-13T11:29:21+00:00Added an answer on May 13, 2026 at 11:29 am
    obj.write(b.toInteger().byteValue())
    

    This approach doesn’t look very efficient.

    Try buffering the I/O:

      public void drain(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[1024];
        int r;
        while ((r = in.read(buffer)) > -1) {
          out.write(buffer, 0, r);
        }
      }
    

    Tune the buffer size as appropriate.

    If the file is large, you may be seeing issues with the operating system doing disk caching (so disk I/O, plus memory management). It is difficult to say for sure from this end of the internet. Try profiling and comparing both approaches (at a bare minimum, you can use the -Xprof command line switch).

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

Sidebar

Related Questions

I'm trying to move a MySQL database from a Linux machine to one running
I'm trying to move changes from a couple of changesets into one changeset on
I'm trying to move the data from one table to another based on names
I'm trying to move some Excel-Data to MySQL, but having troubles with encoding. What
I am trying to move project which was using MySQL database to the one
I have a Web Application that I'm trying to move from Sun Application Server
I'm in the process of trying to move our company from SalesForce to SugarCRM,
I'm trying to move my database.mdf file from a development environment to a SQL
I'm trying to move some table storage in Azure from local storage to the
I am trying to coordinate the move of a site from its current server

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.