Re: [HACKERS] Postgres/PHP/Large Objects - Mailing list pgsql-general

From Chris Bitmead
Subject Re: [HACKERS] Postgres/PHP/Large Objects
Date
Msg-id 3713DEB5.622E101E@bigfoot.com
Whole thread Raw
List pgsql-general
> Ok,  help me out here.  I am trying to deal with at database where I will
> be having HUGE tuples.  (aka text files).  I will blow the 8k window real
> quick.  So I am looking at using the large objects for doing this,  but I
> can not find any info about this and the only way that I can find to create
> and play with the large objects is through C.  I would like to use the PHP
> interface for connecting to the table.  Is there any good info about how to
> use LOs anywhere?  (The quick version:  a table with a doc_ic,  and the
> doc_text.  I want to be able to search it with normal sql calls,  but can't
> find any docs on doing so.)  Let me know.

This probably shouldn't be on the "hackers" list, so I'm re-directing it
to the general list.

I faced the same problem, but in my case I could get away with ignoring
the problem (i.e. staying with the 8k restriction), but I reached the
conclusion that if I truely needed large objects, postgres large objects
are right now not good enough.

Firstly I encountered bugs - I couldn't create more than one LO in the
one session. Secondly, EACH large object results in the creation of two
files in the database. Thirdly, all these files are in the one
directory, potentially clogging up a directory and making bad
performance. Fourthly there don't seem to be many people using it so who
knows what bugs there may be.

If I needed large objects in Postgres I think I would probably write my
own "file system" using postgres pages. Like maybe each 8k record would
be a "page" in the file. And there would be indirect pages that just
point to other pages in the case of a largish file. It gives you random
access like a UNIX file, and you could make the interface look like
postgres large objects in case someone ever fixes them.

If you do want to play with LOs though to see if they can work for you,
there is an SQL call to use them. I forget the name, you'll have to look
it up. But let's say it's called lo_import. You would say

CREATE TABLE foobar ( ptr_to_some_lo oid );
INSERT INTO foobar VALUES (lo_import("this-is-some-file"));

pgsql-general by date:

Previous
From: Thomas Good
Date:
Subject: Re: [GENERAL] Opening two databases at the same time?
Next
From: Guo Ge
Date:
Subject: about transaction