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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:32:49+00:00 2026-06-17T18:32:49+00:00

Postgresql 9.1 NPGSQL 2.0.12 I have binary data I am wanting to store in

  • 0

Postgresql 9.1
NPGSQL 2.0.12

I have binary data I am wanting to store in a postgresql database. Most files load fine, however, a large binary (664 Mb) file is causing problems. When trying to load the file to postgresql using Large Object support through Npgsql, the postgresql server returns ‘out of memory’ error.

I’m running this at present on a workstation with 4Gb RAM, with 2Gb free with postgresql running in an idle state.

This is the code I am using, adapted from PG Foundry Npgsql User’s Manual.

using (var transaction = connection.BeginTransaction())
{
    try
    {
        var manager = new NpgsqlTypes.LargeObjectManager(connection);
        var noid = manager.Create(NpgsqlTypes.LargeObjectManager.READWRITE);
        var lo = manager.Open(noid, NpgsqlTypes.LargeObjectManager.READWRITE);
        lo.Write(BinaryData);
        lo.Close();
        transaction.Commit();
        return noid;
    }
    catch
    {
        transaction.Rollback();
        throw;
    }
}

I’ve tried modifying postgresql’s memory settings from defaults to all manner of values adjusting:

  • shared_buffers
  • work_mem
  • maintenance_work_mem

So far I’ve found postgresql to be a great database system, but this is a show stopper at present and I can’t seem to get this sized file into the database. I don’t really want to have to deal with manually chopping the file into chunks and recreating client side if I can help it.

Please help!?

  • 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-17T18:32:50+00:00Added an answer on June 17, 2026 at 6:32 pm

    I think the answer appears to be calling the Write() method of the LargeObject class iteratively with chunks of the byte array. I know I said I didn’t want to have to deal with chunking the data, but what I really meant was chunking the data into separate LargeObjects. This solution means I chunk the array, but it is still stored in the database as one object, meaning I don’t have to keep track of file parts, just the one oid.

     do 
     {
       var length = 1000;
       if (i + length > BinaryData.Length) length = BinaryData.Length - i;
       byte[] chunk = new byte[length];
       Array.Copy(BinaryData, i, chunk, 0, length);
       lo.Write(chunk, 0, length);
       i += length;
     } (i < BinaryData.Length)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Postgresql database, I have a timestamp without time zone with this value
I am using Npgsql to connect to the postgresql database from visual studio 2010.
I have an application based on 3 tier architecture with postgres database(npgsql) having more
I have some misunderstanding of pooling mechanism in NHibernate with Npgsql (PostgreSQL DB). How
I have project in ASP.NET with postgreSQL database. I do not know what of
I have a ASP.NET project and PostgreSQL database. In my database, I have table
I'm using Npgsql with C# to communicate with my PostgreSQL database. All names used
I'm using Npgsql 2.0.11 under .NET 4.0 to modify a PostgreSQL 9.0 database. The
PostgreSQL 9.2 has native JSON support. I'd like to store human readable config files,
In PostgreSQL 8.3 database I have bookings table referencing booking_transactions table by ID. So

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.