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 1sPbTz-005PHb-FY for pgsql-general@arkaria.postgresql.org; Fri, 05 Jul 2024 05:27:43 +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 1sPbTw-006MQH-UG for pgsql-general@arkaria.postgresql.org; Fri, 05 Jul 2024 05:27:41 +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 1sPbTw-006MPT-JK for pgsql-general@lists.postgresql.org; Fri, 05 Jul 2024 05:27:41 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sPbTq-000TqM-GM for pgsql-general@lists.postgresql.org; Fri, 05 Jul 2024 05:27:40 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52ea2ce7abaso1086418e87.0 for ; Thu, 04 Jul 2024 22:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720157253; x=1720762053; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=K44jqNai2zA5yo7km31mRRfKacZ5A63CBe59cBRsYsg=; b=W2ao5LCQggndRpXooWo5jHzr0J/t405Uo9s32MjrQ8IFXC8pju1PaofKQN9SQcACDW fMvzrv5FQflvd6rgiaakEQjldctch0WpF6Yjkuabewb0au57pG0RcYqtR/8kjR0578J8 gblzgxG54LRHHZqdj06PHI8dF0Zar5nKnFp/VzVMauwc5xfTgLmw9QbpmEXya1AfX/u1 NG5Jp1qCJ8/4gkWYUJScp8hfSBv+Rik72vcH6fA38R5v42h+gVfXrjgHaQWvJGUiQ73i x4hvTg22iA1IWwSQkOgJo+OCkDRXHelEbwovm03XFlHfPJMl39l23RXL7Pl/RKsvvPtc 8Jag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720157253; x=1720762053; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K44jqNai2zA5yo7km31mRRfKacZ5A63CBe59cBRsYsg=; b=NXGzTGHqFyEk4QRj61lCX6WY/PElfHjcJPObM4UCWr6Y0i7v8XjdHHVnkVLHHSEoNU MYce3/mYxbxCMv4LC7Ui1PegYsoUYPYoUELzIJ14Wn1bMuXOZUxqUZ+ndSAtajrtR5JI 5AYWQEUAx15HYCOJuRIJg/ct4Nkzf8fiXqvkcRNlmjthkaeC4s3gV6vI9yR9KCBuwIab ln1xakQC5CH1gmBkXoVmjoef24jYP2H3djrVc1OCAUDxjYIXL5q2tndoUmTOm7O2VMSg 7BjyPV6iasxdt53PO6zgo91H0PVyQEMnD6epZo/dI9hwRkWxz4MQHRRup+t4+Xv8A4kF Vlbw== X-Forwarded-Encrypted: i=1; AJvYcCULSL4hvnn57cXnHIrmv+UoPiM+tx7p63+fOtVuq1uYuwaeXrC7Q8d1eEG/lYl5t2xeqk6EcKRHyGiV/NAUrvWWoXmBtDF6kwzGiprkqlrD0vTm X-Gm-Message-State: AOJu0Yz6mCF7oMRcCQ++kfxEkUA3A5sRcU+9H6x6vHHZHMUv0RXFKIo2 KmUNp0hvNqdG06Rj+wnQYVZt44w+hxibgm7flYYTwp/PAn9uag5/tSMO9c6meMnofhWi/hL0NkV TATzbU01XrQNutXzBrkycpUaXsc4= X-Google-Smtp-Source: AGHT+IHzIFMOSlDG9nEbK6hn8x/yZbHnGs7dyw6rep+zKzeZAP+llPvb0TfDTwXM5ot5aAtHnHLYpsj4Dsqe41NKIzA= X-Received: by 2002:a05:6512:62:b0:52c:e1cd:39b7 with SMTP id 2adb3069b0e04-52ea061a3d2mr2496386e87.5.1720157252612; Thu, 04 Jul 2024 22:27:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Fri, 5 Jul 2024 17:27:20 +1200 Message-ID: Subject: Re: Design strategy for table with many attributes To: Lok P Cc: "David G. Johnston" , pgsql-general Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 5 Jul 2024 at 17:07, Lok P wrote: > Also I understand the technical limitation of the max number of columns p= er table is ~1600. But should you advise to restrict/stop us to some low nu= mber long before reaching that limit , such that we will not face any anoma= lies when we grow in future. And if we should maintain any specific order i= n the columns from start to end column in the specific table? Something else you may wish to consider, depending on the column types of your 900+ columns is the possibility that some INSERTs may fail due to row length while others with shorter variable length values may be ok. Here's a quick example with psql: select 'create table a (' || string_agg('a'||x||' text not null default $$$$',',') || ')' from generate_series(1,1000)x; \gexec insert into a default values; INSERT 0 1 again but with a larger DEFAULT to make the tuple larger. select 'create table b (' || string_agg('a'||x||' text not null default $$hello world$$',',') || ')' from generate_series(1,1000)x; \gexec insert into b default values; ERROR: row is too big: size 12024, maximum size 8160 There is a paragraph at the bottom of [1] with some warnings about things relating to this. The tuple length would be fixed for fixed-length types defined as NOT NULL. So, if you have that, there should be no such surprises. David [1] https://www.postgresql.org/docs/current/limits.html