Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id DECDBB5DBE5 for ; Wed, 18 May 2011 20:06:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 51796-07 for ; Wed, 18 May 2011 23:06:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f46.google.com (mail-bw0-f46.google.com [209.85.214.46]) by mail.postgresql.org (Postfix) with ESMTP id AEE5FB5DBE1 for ; Wed, 18 May 2011 20:06:37 -0300 (ADT) Received: by bwz15 with SMTP id 15so2926586bwz.33 for ; Wed, 18 May 2011 16:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=X46PAwdl/6dBSocLezz1K/KHwKu6116UdyQuwUyvt04=; b=pcjaqpOAYqY3gv51jyQv/36VQkH2xQ9Jt6kveP6kOyFnHIGBolr8JmZKQrYxIAma+Y QFU0HuNft3apWesIzpvwiSJpLbZDi8ayh4cGfLDL/uRlxcz7fZfCb7SGviA/dThbf409 4IIo30GJdcS9JcuzrPlAZMBsUyfNAYX4oudjo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=L/UEYe7NDy2BPRC4Wlpt7A3qJ76nz2y5x6XptJP2Im2kPw4PT1qj/g3fDZsM5OpFOh RgQaBMzjKXQ2Em8+Zjn/qele+/o9TPrLHXwj13XeHwNPEIIB94tCenW4Tu5/xwDs4mCa VLkz+ty9OwEAJBRk9QSP6dCFNsKr8nKpyGc9Q= MIME-Version: 1.0 Received: by 10.204.233.14 with SMTP id jw14mr2493565bkb.40.1305759996926; Wed, 18 May 2011 16:06:36 -0700 (PDT) Received: by 10.204.41.14 with HTTP; Wed, 18 May 2011 16:06:36 -0700 (PDT) In-Reply-To: <4DD42A1C.30202@encs.concordia.ca> References: <4DD42A1C.30202@encs.concordia.ca> Date: Wed, 18 May 2011 17:06:36 -0600 Message-ID: Subject: Re: column type for pdf file From: Eric McKeeth To: emilu@encs.concordia.ca Cc: pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=485b3979da84c75b8104a394f02e X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.334 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201105/110 X-Sequence-Number: 35394 --485b3979da84c75b8104a394f02e Content-Type: text/plain; charset=ISO-8859-1 On Wed, May 18, 2011 at 2:20 PM, Emi Lu wrote: > Hello, > > To save pdf files into postgresql8.3, what is the best column type? > > bytea, blob, etc? > > Thank you, > Emi > Everyone else has pointed out reasons for not doing this, and I agree with them that in the large majority of cases just storing a reference to a file stored outside the database is preferable. However, to answer the question you asked, my rule of thumb is that if you need to store binary data in the database is to use a bytea column, unless you need the random access capabilities that the large object interface provides. A bytea column is typically easier to use, and has proper transactional behavior, enforcement of referential integrity, etc. -Eric --485b3979da84c75b8104a394f02e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Wed, May 18, 2011 at 2:20 PM, Emi Lu <emilu@encs.concord= ia.ca> wrote:
Hello,

To save pdf files into postgresql8.3, what is the best column type?

bytea, blob, etc?

Thank you,
Emi

Everyone else = has pointed out reasons for not doing this, and I agree with them that in t= he large majority of cases just storing a reference to a file stored outsid= e the database is preferable. However, to answer the question you asked, my= rule of thumb is that if you need to store binary data in the database is = to use a bytea column, unless you need the random access capabilities that = the large object interface provides. A bytea column is typically easier to = use, and has proper transactional behavior, enforcement of referential inte= grity, etc.

-Eric
--485b3979da84c75b8104a394f02e--