Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ol8YH-0000Zm-Q7 for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 12:52:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ol8YG-0008Ck-Ly for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 12:52:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ol8WY-0002Gh-6g for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 12:50:18 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ol8WV-0005q7-Nb for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 12:50:17 +0000 Received: by mail-pj1-x1034.google.com with SMTP id q10-20020a17090a304a00b0020b1d5f6975so16728687pjl.0 for ; Wed, 19 Oct 2022 05:50:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=tmUSX1Xl9i4GfrG4Tic6nTqe2IN+RLcosWcZ/JynJ0c=; b=Qc92kmXkIqj2lpzwQf266GbvacXdu3RLl/KyPY53bYB+eT4tCgCS8IpD47+7xQ0K0g /8lGc7R66LxGs3p9Hw+Om0EwJq5BLNzKoHPxJJ5pX+hmyxP6u5ANXr9pQaMvIJX2Xout vuA37ZHhLMqqCzjSyzSAwhb+XDeU/V3SOzOOKH6AG1ZcAGvJw9rRiEiDPk47d+g/JNya l5wqDb40awVMVwi6vTOeeskB2NKc7i/xuNC4fg+ipoc9NQxGnHBYTyvQX89SXToASWHw OyBSrMBSYZ+9jxEtw2g5gbEVTMQ8Ef+wvQxENUKcC5A13ja4jfqoG7qcwxEZN6Ldxhn3 HVOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tmUSX1Xl9i4GfrG4Tic6nTqe2IN+RLcosWcZ/JynJ0c=; b=LPeFNaHnkj6RKqwTHLAeKTEWr6pK+b/0RILUtbhXRh5DZST5pXmyU0haWm0x8QdkEx iRSAuVOvunzFDsj6Gy/Fc+FhU4gNlmpqD+uy4OuDJZSOwImaye6xwP/2f0WjSSGNaV2K NCjSygqVOXmKR4D8o3g86Frj4WujB4Xd903LZCViGEtfo3L3OjRktHWhKD8eSzbvvLAL oNuIS31TuUMkC2iyEjpk8s4y33KURvsqZsE7hAHPRTVXoiaQd42yRC4ZzEgxGW1Q2D9l BjBiqi24jkKDEJdQxiZiBH1PrKEgM0ItAcM1PbCxX8LI9m9FdYrgEztkBbqI0VU8+HPI c7Kg== X-Gm-Message-State: ACrzQf3bvR0LrcEYpvNloabc3CfQkdpx0mM2n9eEoZrrx4CoJyhXpXeN HOMWmgmmBsMz2ha9BSVET3E= X-Google-Smtp-Source: AMsMyM4yBGbTSH1+snD7JO3a2wsS9zbOdanqhR1eViViUO9omO9ZLv9GnbxBspHkwgiuTyY7PPw2PA== X-Received: by 2002:a17:90b:3e82:b0:20d:2fa1:d08d with SMTP id rj2-20020a17090b3e8200b0020d2fa1d08dmr46157108pjb.162.1666183814433; Wed, 19 Oct 2022 05:50:14 -0700 (PDT) Received: from smtpclient.apple ([2403:6200:88a0:3eae:6448:df4f:17a6:764b]) by smtp.gmail.com with ESMTPSA id o63-20020a62cd42000000b0056258a3606csm11210258pfg.215.2022.10.19.05.50.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Oct 2022 05:50:13 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-99C71C7D-BDA4-491F-B7D0-6A9CB8B81A80 Content-Transfer-Encoding: 7bit From: esconsult1@gmail.com Mime-Version: 1.0 (1.0) Subject: Re: How to store "blobs" efficiently for small and large sizes, with random access Date: Wed, 19 Oct 2022 19:50:10 +0700 Message-Id: <0BE00147-79F4-45E8-BDEF-E809BCFAA668@gmail.com> References: Cc: Andreas Joseph Krogh , pgsql-general@lists.postgresql.org In-Reply-To: To: Dominique Devienne X-Mailer: iPhone Mail (19G82) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail-99C71C7D-BDA4-491F-B7D0-6A9CB8B81A80 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable We had the same thought of storing the blobs inside LO=E2=80=99s as well man= y years ago. But ultimately chose cloud storage and stored a pointer in the database inst= ead. Now that we are approaching a terabyte of just normal data I don=E2=80=99t r= egret this decision one bit. Just handling backups and storage is already a c= hore.=20 Data in S3 compatible storage is very easy to protect in numerous ways. We have one set of code responsible for uploading, downloading and deleting t= he files themselves. One downside? Occasionally an S3 delete fails and now and again a file or tw= o gets orphaned. But we=E2=80=99ve never not found a file pointed to from ou= r attachments table in 11 years. We also only store pathnames/base names so we can easily move storage provid= ers if we decide to go on Prem. There is absolutely no upside to storing files in the db if you anticipate a= ny kind of growth or significant volume. Ericson Smith CTO Travel Agency Tribes Sent from my iPhone > On 19 Oct 2022, at 7:01 PM, Dominique Devienne wrote= : >=20 > =EF=BB=BF >> On Wed, Oct 19, 2022 at 1:38 PM Andreas Joseph Krogh = wrote: >=20 >> There's a reason =E2=80=9Ceverybody=E2=80=9D advices to move blobs out of= DB, I've learned. >=20 > I get that. I really do. But the alternative has some real downsides too. > Especially around security, as I already mentioned. That's why I'd like if= possible > to get input on the technical questions of my initial post. >=20 > That's not to say we wouldn't ultimately move out the big blobs outside th= e DB. > But given how much that would complexify the project, I do believe it is b= etter > to do it as a second step, once the full system is up-and-running and test= ing at > scale has actually been performed. >=20 > We've already moved other kind of data to PostgreSQL, from SQLite DBs (tho= usands) this time, > and ported "as-is" the sharding done on the SQLite side to PostgreSQL (des= pite TOAST). > And so far, so good. With good ingestion rates. And decent runtime access t= o data too, > in the albeit limited testing we've had so far. >=20 > Now we need to move this other kind of data, from proprietary DB-like file= s this times (thousands too), > to finish our system, and be able to finally test the whole system in earn= est, and at (our limited internal) scale. >=20 > So you see, I'm not completely ignoring your advise. >=20 > But for now, I'm inquiring as to the *best* way to put that data *in* Post= greSQL, > with the requirements / constraints I've listed in the first post. > It may indeed be a bad idea long term. But let's make the most of it for n= ow. > Makes sense? Am I being unreasonable here? --DD --Apple-Mail-99C71C7D-BDA4-491F-B7D0-6A9CB8B81A80 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable We had the same thought of storing the blob= s inside LO=E2=80=99s as well many years ago.

But ultimat= ely chose cloud storage and stored a pointer in the database instead.
<= div>
Now that we are approaching a terabyte of just normal dat= a I don=E2=80=99t regret this decision one bit. Just handling backups and st= orage is already a chore. 

Data in S3 compatib= le storage is very easy to protect in numerous ways.

We have one set of code responsible for uploading, downloading and deletin= g the files themselves.

One downside? Occasionally a= n S3 delete fails and now and again a file or two gets orphaned. But we=E2=80= =99ve never not found a file pointed to from our attachments table in 11 yea= rs.

We also only store pathnames/base names so we c= an easily move storage providers if we decide to go on Prem.

<= /div>
There is absolutely no upside to storing files in the db if you an= ticipate any kind of growth or significant volume.

= Ericson Smith
CTO
Travel Agency Tribes

Sent from my iPhone

On 19 Oct 2022, at 7:01 PM, Dominique Devienne <ddevienne@gmail.com>= wrote:

=EF=BB=BF
On Wed, Oct 19, 2022 at 1:38 PM A= ndreas Joseph Krogh <andreas@visena= .com> wrote:
There's a reason =E2=80=9Ceverybody=E2=80=9D= advices to move blobs out of DB, I've learned.

<= /div>
I get that. I really do. But the alternative has some real downsid= es too.
Especially around security, as I already mentioned. That's= why I'd like if possible
to get input on the technical questions o= f my initial post.

That's not to say we wouldn't ul= timately move out the big blobs outside the DB.
But given how much= that would complexify the project, I do believe it is better
to d= o it as a second step, once the full system is up-and-running and testing at=
scale has actually been performed.

We've= already moved other kind of data to PostgreSQL, from SQLite DBs (thousands)= this time,
and ported "as-is" the sharding done on the SQLite sid= e to PostgreSQL (despite TOAST).
And so far, so good. With good in= gestion rates. And decent runtime access to data too,
in the albei= t limited testing we've had so far.

Now we need to m= ove this other kind of data, from proprietary DB-like files this times (thou= sands too),
to finish our system, and be able to finally test the w= hole system in earnest, and at (our limited internal) scale.
<= br>
So you see, I'm not completely ignoring your advise.

But for now, I'm inquiring as to the *best* way to put that d= ata *in* PostgreSQL,
with the requirements / constraints I've list= ed in the first post.
It may indeed be a bad idea long term. But l= et's make the most of it for now.
Makes sense? Am I being unreason= able here? --DD
= --Apple-Mail-99C71C7D-BDA4-491F-B7D0-6A9CB8B81A80--