Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1udFCE-0054F6-Jr for pgsql-general@arkaria.postgresql.org; Sat, 19 Jul 2025 21:34:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1udFCD-008Iux-9c for pgsql-general@arkaria.postgresql.org; Sat, 19 Jul 2025 21:34:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1udFCC-008Iuo-Jt for pgsql-general@lists.postgresql.org; Sat, 19 Jul 2025 21:34:16 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1udFCA-008BDs-0w for pgsql-general@lists.postgresql.org; Sat, 19 Jul 2025 21:34:15 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 3B84BEC01F9; Sat, 19 Jul 2025 17:34:13 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Sat, 19 Jul 2025 17:34:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1752960853; x=1753047253; bh=gdly95/vCfwWvEziQxfjMLFxNg4SAuqA/3QzVML9wUw=; b= Fl56okU+NzFD7F+S+0J6mLcOAOOc24dn8rS0XzQmWwEFC7e1c3tqyBYHK1lFJx2n /ZTLjpfUAc1Z8vlD2Yqak3ROL8L73UWqUFuq+gyDbYkUezxlu9jckh9SCktPaDSc FjqlAMTfmkZk4fTft26ph/erec3nSZTWrgVkNWQtIM+yQ1u6hNJ37Tu3qo0AGlZt qGbA1CjyfF3h/MFKBcIEAQ9RiRJvWqDtFs3h2HjFtqQybgac2H+CYZugPSmBYnue c6fLlMFbXdd+QvJd2K1r9MTkcIwk23dWZ9A0tIrKaKerm4PXNBEXglmoLDisc/Eb xTNTp6OyIV1/PvbXrsHdLA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1752960853; x= 1753047253; bh=gdly95/vCfwWvEziQxfjMLFxNg4SAuqA/3QzVML9wUw=; b=X 4F0mxLooF87CGEyUW6K3OU43jep1/StGsZHs4motKROlLQnO+lzmcqYGcQbCaphs +u/6AHHFN12j/LFt4E5yBLBg/tVREOb09doDN7EOuh4Ev6433YX5dCaSLuTOyPUr YDz1MaaS+kHE+Ex4Sj4oGXwATO2316hBVpccEGtcUaLHTbM3C2IHaAlPXOP0Hn+X ka5A++yM+kp/E3F5MGcEjlXOOzL8paGuKGjAs2kD+qm8zxMNG1tiSfcPyKitHPKm 9vrONSG49DesQxv3UBr6bM8uQPekWU3bhhOLmY45Ed5xEhG5Hx+CxkwPMbxqYLzd P2ZGDeVB87+PsWj2BsxCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeijeegvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghn ucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqe enucggtffrrghtthgvrhhnpefgudefkefhveefleevieeuveehvdduudekuddvvdelhfeu ueeijedtuedvvedvueenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepgedpmhhoug gvpehsmhhtphhouhhtpdhrtghpthhtohepvhgvvghmrgdttddttdesghhmrghilhdrtgho mhdprhgtphhtthhopehmmhhonhgtuhhrvgesghhmrghilhdrtghomhdprhgtphhtthhope gurghvihgurdhgrdhjohhhnhhsthhonhesghhmrghilhdrtghomhdprhgtphhtthhopehp ghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 19 Jul 2025 17:34:12 -0400 (EDT) Message-ID: Date: Sat, 19 Jul 2025 14:34:11 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Performance of JSON type in postgres To: veem v Cc: Merlin Moncure , "David G. Johnston" , pgsql-general References: <8efa554c-ba95-43d5-953c-def0d53dca9e@aklaver.com> <289f005c-4a80-4098-bf58-f53e06bb7f8c@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/19/25 14:19, veem v wrote: > > On Sun, 20 Jul 2025 at 02:29, Adrian Klaver > wrote: > > On 7/19/25 13:39, veem v wrote: > > > > I thought you are answered that with your tests above? At least for the > Postgres end. As to the Snowflake end you will need to do comparable > tests for fetching the data from Postgres and transforming it. > > Thank you Adrian. > Yes will try to test the load from postgres to snowflake to see if any > specific format makes a difference in such a situation(mainly > considering JSONB seems postgres native only). > > Additionally I am unable to test upfront, but few teammates are saying > below. Are these really true? Wants to know from experts here, Again as I mentioned at the beginning of this thread many of the answers can be found here: https://www.postgresql.org/docs/current/datatype-json.html > > 1)The lack of detailed statistics on data distribution within JSONB > columns can hinder the query planner from making optimal choices, > sometimes leading to slower execution or a reliance on sequential scans > even when indexes exist. Storing extensive or deeply nested structures > within a single JSONB document can lead to document bloat. 8.14.4. jsonb Indexing > > 2)Loss of Formatting and Order: The binary format of JSONB doesn't > preserve the original order of keys, whitespace, or duplicate keys in > the JSON input. "By contrast, jsonb does not preserve white space, does not preserve the order of object keys, and does not keep duplicate object keys. If duplicate keys are specified in the input, only the last value is kept." > > 3)Lack of Type Safety and Schema Enforcement: JSONB provides no inherent > schema or type validation. This means you can easily insert inconsistent > data types for the same key across different rows, making data > management and querying challenging. "JSON data types are for storing JSON (JavaScript Object Notation) data, as specified in RFC 7159. Such data can also be stored as text, but the JSON data types have the advantage of enforcing that each stored value is valid according to the JSON rules. " There is no schema validation. > > 4)No Native Foreign Key Support: You cannot directly define foreign key > constraints within a JSONB column to enforce referential integrity with > other tables. Table 8.23. JSON Primitive Types and Corresponding PostgreSQL Types If you look at that you will see that JSON(B) types do not cover the range that Postgres types do, making it difficult to map directly to Postgres tables even if there where FK's allowed. To me it looks like you really need to store the data in defined Postgres tables. > Regards > Veem -- Adrian Klaver adrian.klaver@aklaver.com