Re: large object write performance - Mailing list pgsql-performance

From Bram Van Steenlandt
Subject Re: large object write performance
Date
Msg-id 561661A8.90301@diomedia.be
Whole thread Raw
In response to Re: large object write performance  ("Graeme B. Bell" <graeme.bell@nibio.no>)
Responses Re: large object write performance
List pgsql-performance


Op 08-10-15 om 14:10 schreef Graeme B. Bell:
On 08 Oct 2015, at 13:50, Bram Van Steenlandt <bram@diomedia.be> wrote:
1. The part is "fobj = lobject(db.db,0,"r",0,fpath)", I don't think there is anything there
Re: lobject

http://initd.org/psycopg/docs/usage.html#large-objects

"Psycopg large object support *efficient* import/export with file system files using the lo_import() and lo_export() libpq functions.”

See *
I was under the impression they meant that the lobject was using lo_import and lo_export.
I can't seem to find how to use lo_import en export, I searched google and came to the conclusion the lobject was the way to go.
>>> x.lo_import()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'psycopg2._psycopg.connection' object has no attribute 'lo_import'

>>> from psycopg2.extensions import lo_importTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name lo_import

Also:
http://initd.org/psycopg/docs/connection.html
lobject([oid[, mode[, new_oid[, new_file[, lobject_factory]]]]])

Return a new database large object as a lobject instance.

See Access to PostgreSQL large objects for an overview.

Parameters:
  • oid – The OID of the object to read or write. 0 to create a new large object and and have its OID assigned automatically.
  • mode – Access mode to the object, see below.
  • new_oid – Create a new object using the specified OID. The function raises OperationalError if the OID is already in use. Default is 0, meaning assign a new one automatically.
  • new_file – The name of a file to be imported in the the database (using the lo_import() function)
  • lobject_factory – Subclass of lobject to be instantiated.


lobject seems to default to string handling in Python
That’s going to be slow.
Try using lo_import / export?

Graeme Bell


pgsql-performance by date:

Previous
From: "Graeme B. Bell"
Date:
Subject: Re: large object write performance
Next
From: "Graeme B. Bell"
Date:
Subject: Re: large object write performance