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 1ol8lI-0001VY-KJ for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 13:05:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ol8lH-0001cj-Bx for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 13:05:31 +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 1ol8lH-0001cZ-1s for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 13:05:31 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ol8lA-0005wx-JW for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 13:05:30 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id F2A665C0094; Wed, 19 Oct 2022 09:05:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 19 Oct 2022 09:05:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1666184723; x=1666271123; bh=F AlEncQZV8VRd4FGIrV0w1LL/dsnm1L7qt85fNLWeXY=; b=cSq0KvxN1NsRrUucX mIWEUAJb2PXLQbTohApFdN16dYjkX00CWipOxJpTNOfE5lQPvOPU0SAq6S/IeblT tKSKxIVrHDJMmmqGKVDatmMECdK/cVh7nsF7PytggkzxQIXCni8NBJxfb2aAipX3 0hQPCnAYo5s9jFw8dGAKNzde4MAgf7T4SkGdBUrxVY3Zo7McwIL7KgV4U3zcSO7m RMSkthHiIsp3vNZt8je/8tJcoRQ0cT5qscPa2x7CSqCTKrsERMtl5LzOszHYG4aZ vWEk9DzWI4wZuqlngxl3e6UHLlCiVgf0h/sDaZClDOp72Fz4I37OFz9B9MpPgVkV 9+GiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeelgedgheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepkedthfekveduuefgueelteekgfejgeekueduudeuveeu vddufffggfetiefhvdefnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghdpvg hnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 19 Oct 2022 09:05:23 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 29DE770; Wed, 19 Oct 2022 15:05:21 +0200 (CEST) Date: Wed, 19 Oct 2022 15:05:21 +0200 From: Alvaro Herrera To: Dominique Devienne Cc: pgsql-general@lists.postgresql.org Subject: Re: How to store "blobs" efficiently for small and large sizes, with random access Message-ID: <20221019130521.5ckagzlnsevg4t3n@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Oct-19, Dominique Devienne wrote: > Upfront, I have to state that I'm not keen on lo, because of security > considerations. We store blobs in many different schemas, and users > can access some schemas, and not others. So the fact the lo table is > unique for the whole database would allow users to see blobs from any > schema, as I understand it. Right? OTOH, lo has random access, which I > also need... Generally speaking, bytea sucks for random access, because if a TOAST item is compressed, it has to be always read from the beginning in order to decompress correctly. However, if you set ALTER TABLE tab ALTER COLUMN byt SET STORAGE EXTERNAL then compression is not used, and random access becomes fast. https://www.postgresql.org/docs/15/sql-altertable.html -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "No hay hombre que no aspire a la plenitud, es decir, la suma de experiencias de que un hombre es capaz"