Note that there are some explanatory texts on larger screens.

plurals
  1. POHow come PostgreSQL 9.2.1 can store Large Object bigger than 2GB?
    primarykey
    data
    text
    <p>I am totally new to PostgreSQL and database, and trying to do some tests about the large object.</p> <p>I just found that 8GB file could be saved to Postgres.</p> <p>However the document says the max for large object (<code>pg_largeobject</code> storage) is 2GB.</p> <p><a href="http://www.postgresql.org/docs/9.2/static/lo-intro.html" rel="nofollow">http://www.postgresql.org/docs/9.2/static/lo-intro.html</a></p> <p>Am I missing something here?</p> <p>Select <code>version()</code> shows:</p> <blockquote> <p>PostgreSQL 9.2.1 on x86_64-unknow-linux-gnu, compiled by gcc (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4), 64-bit</p> </blockquote> <p>here is my code in case you are interested:</p> <pre><code>private long insertLargeObject(UsSqlSession session, FileEntity fileEntity) throws SQLException, FileNotFoundException, IOException{ LargeObjectManager lobj = getLargeObjectAPI(session); long oid = lobj.createLO(); LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE); try(FileInputStream fis = new FileInputStream(fileEntity.getFile())){ int bufSize = 0x8FFFFFF; byte buf[] = new byte[bufSize]; int s = 0; int tl = 0; while( (s = fis.read(buf, 0, bufSize)) &gt; 0 ) { obj.write(buf, 0, s); tl += s; } } obj.close(); return oid; } </code></pre> <p><strong>UPDATE:</strong></p> <p>The size of the <code>pg_largeobject</code> is 11GB, and <code>pg_largeobject_metadata</code> says there is one line which means only one large object exists. </p> <pre><code>select sum(length(lo.data)) from pg_largeobject lo where lo.loid=1497980; </code></pre> <p>returns <code>4378853347</code>. </p> <p><strong>UPDATE:</strong></p> <pre><code>public File findLargeObject(UsSqlSession session, long oid) throws SQLException, FileNotFoundException, IOException{ LargeObjectManager lobj = getLargeObjectAPI(session); LargeObject obj = lobj.open(oid, LargeObjectManager.READ); int bufSize = 0x8FFFFFF; byte buf[] = new byte[bufSize]; int s = 0; int tl=0; File file = new File("e:/target-file"); try(FileOutputStream output = new FileOutputStream(file)){ while( (s = obj.read(buf, 0, bufSize)) &gt; 0 ){ output.write(buf, 0, s); tl += s; } output.flush(); } obj.close(); return file; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload