Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvVMl-0006VV-Qj for pgsql-general@arkaria.postgresql.org; Thu, 30 Aug 2018 22:24:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fvVMj-00041b-2x for pgsql-general@arkaria.postgresql.org; Thu, 30 Aug 2018 22:24:37 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvVMi-00041U-H7 for pgsql-general@lists.postgresql.org; Thu, 30 Aug 2018 22:24:36 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fvVMf-0007mg-H2 for pgsql-general@postgresql.org; Thu, 30 Aug 2018 22:24:35 +0000 Received: by mail-pg1-x543.google.com with SMTP id b129-v6so4500241pga.13 for ; Thu, 30 Aug 2018 15:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=Bp6Vhpl8yd6RDJ0b6YHsAowileAgQJycAeuB77Ur6y8=; b=FNl/ndbhg8jVCINdtiPq6pSjnw+pgLDmHbPW+0fEvPQelZYID+sRE0VkEFLH5HpBjw 2MX7cSArt0zvxuyFRoR2CAzyUl7F7Vy+PjUjyN7uoeuzkllRsPN8Ph/fOALSWR23VrxM Q5+LOKmNx7MuwWFz5XHo7EdQpqhKHzNg8mGriBZMBNRZ3nMmdUOoVmhJF42TcobMPIfs Ria/pFDtupHoJEH07ON9HZBsP60D6ZMvxzZjT/2Jgf283Z5D9gFIS5qks7/LRCX6s6vQ LajdLQSD4pWw49H2u105HdNUWve7TbSR9cRfqp4wcs20p3DWQQ05kJrunNRP2rBkYMqT 0NyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=Bp6Vhpl8yd6RDJ0b6YHsAowileAgQJycAeuB77Ur6y8=; b=k/JpINnjn98bSnIG6Jr7GcbWvJQChUINdJ/HNV62X1OBrErwLzdmGyH3xZusTDyIaw aNBW7hjnglF5g6dVidClhyljq2UaeqPol48CXonXd7OklCPYbd4L0gI6no3Ee8MmJO+C yi18Pzkf1Fzu/f911pZlQWL9d/2epiGdptn7icrjEFRofvTf7wGikTBfrImrAn8upVy/ M5MHUzt38iMgJURseSJCfnA6XVSqqsrzgJQTY7wypgYUWEEqVP/cCPc46dqaHSBF3BFa 53zwWppEDhxHOnendeYH8PHbvexdla8Ar5C6L0e7Wjpv4Hd68i7qY2DbX+ZUnqOEZMcc NMow== X-Gm-Message-State: APzg51CXFzPUN9NEinGQv18CFxdAOnhQ6S7I0rsrpSfYiH5PBV6BpmO+ E8FjDE8Mse9WWAAOpG3BVWOYK5Xp X-Google-Smtp-Source: ANB0VdYIum0wjVb5L+C1GxsuZsfnWvFWw4Tx5p2vcOC8BKbSfk6ZZMk2FlT0lWSLlUMJHKxzx5TIIg== X-Received: by 2002:a63:804a:: with SMTP id j71-v6mr9779032pgd.171.1535667872276; Thu, 30 Aug 2018 15:24:32 -0700 (PDT) Received: from tim-desktop (2001-44b8-31f2-bb00-51ac-5174-403e-3f0d.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:51ac:5174:403e:3f0d]) by smtp.gmail.com with ESMTPSA id t9-v6sm14101679pgi.87.2018.08.30.15.24.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 15:24:31 -0700 (PDT) References: User-agent: mu4e 0.9.18; emacs 26.1 From: Tim Cross To: a <372660931@qq.com> Cc: pgsql-general Subject: Re: Ways to deal with large amount of columns; In-reply-to: Date: Fri, 31 Aug 2018 08:24:28 +1000 Message-ID: <87a7p3ijc3.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk a <372660931@qq.com> writes: > Hi all: > > > I need to make a table contains projected monthly cashflow for multiple agents (10,000 around). > > > Therefore, the column number would be 1000+. > > Not sure your data model is correct. Typically, with something like this, increasing the number of agents would result in tables with more rows rather than more columns. Tables with large numbers of columns is often a 'code smell' and indicates the underlying data model needs to be reviewed. Designs which result in new columns being required because you are adding new data sources is almost certainly an indication of the need to review the data model. Postgres (and many other databases) have lots of functionality to help deal with tables that have large numbers of rows, but working with tables that have large numbers of columns has less functionality and options. While it is very tempting to create a table and then start coding, you will almost always get a much better result and simpler code if you spend some initial time to really analyse your domain, understand the data elements and how they relate to each other, map them out into a data model and then start development. Have a look at https://en.wikipedia.org/wiki/Database_normalization for some background on the normal forms and why they are useful. HTH Tim -- Tim Cross