From: | Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr> |
---|---|
To: | Hanno Schlichting <hanno(at)hannosch(dot)eu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Tweaking bytea / large object block sizes? |
Date: | 2011-06-12 19:02:26 |
Message-ID: | 1307905346.2276.14.camel@asus-1001PX.home |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Le dimanche 12 juin 2011 à 18:00 +0200, Hanno Schlichting a écrit :
> I'm looking into storing binary data in Postgres and trying to
> understand how data is actually stored in the database. The dataset
> I'm looking at is images, photos, pdf documents which should commonly
> be at a minimum 100kb, on average 10mb and can scale up to 100mb for
> each document. I want to store this data in the database, as I need
> transactional integrity and want to avoid the extra complexity of
> managing shared filesystems between a number of frontend application
> servers and database backends.
>
I had a similar requirement for the app that's in my sig. It uses a
PostgreSQL database, but the binary content of the documents resides in
an SQLite database.
That way, my PostgreSQL database remains very small, easy to manage and
backup. I have a separate procedure to do incremental backups of the
documents as they are added.
The SQLite db looks like this :
CREATE TABLE tbldocument_content (id_courrier INTEGER NOT NULL PRIMARY
KEY, content blob);
CREATE TABLE tbldocument_state (id_courrier INTEGER NOT NULL, backed_up
integer default 0, date_created date default (date('now')), FOREIGN
KEY(id_courrier) REFERENCES tbldocument_content(id_courrier));
CREATE INDEX tbldocument_state_backed_up_idx ON
tbldocument_state(backed_up);
CREATE INDEX tbldocument_state_id_courrier_idx ON
tbldocument_state(id_courrier);
CREATE TRIGGER create_document_state AFTER INSERT ON
tbldocument_content
BEGIN
INSERT INTO tbldocument_state (id_courrier) VALUES (NEW.id_courrier);
END;
CREATE TRIGGER drop_document_state AFTER DELETE ON tbldocument_content
BEGIN
DELETE FROM tbldocument_state WHERE id_courrier=OLD.id_courrier;
END;
id_courrier is generated by the PostgreSQL db.
Works great. You can't see it on in action on the web site with the demo
account, though.
--
Vincent Veyron
http://marica.fr/
Logiciel de gestion des sinistres et des contentieux pour le service juridique
From | Date | Subject | |
---|---|---|---|
Next Message | Boszormenyi Zoltan | 2011-06-12 19:14:41 | Re: FILLFACTOR and increasing index |
Previous Message | Hanno Schlichting | 2011-06-12 16:00:19 | Tweaking bytea / large object block sizes? |