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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 270k
  • Answers 270k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The issue is that you've violated the one definition rule.… May 13, 2026 at 1:30 pm
  • Editorial Team
    Editorial Team added an answer If there are no other references to _watcher, then there… May 13, 2026 at 1:30 pm
  • Editorial Team
    Editorial Team added an answer I finally managed to get this to work. I followed… May 13, 2026 at 1:30 pm

Related Questions

Running sql server 2005 I have database A. I am trying to restore from
I am in the early stages of planning and designing a custom accounting application
I am trying to move from Emacs v22.3.1 to v23.1.1 and all was going
I am trying to use the convert extension in Mercurial to create a repository
I am trying to execute a certain task where i am required to read

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.