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 1kPn6H-0003yO-Jw for pgsql-admin@arkaria.postgresql.org; Tue, 06 Oct 2020 13:33:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kPn6G-00007S-Do for pgsql-admin@arkaria.postgresql.org; Tue, 06 Oct 2020 13:33:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPn6G-00007L-4B for pgsql-admin@lists.postgresql.org; Tue, 06 Oct 2020 13:33:52 +0000 Received: from mout.gmx.net ([212.227.15.15]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPn6D-0008OP-Jl for pgsql-admin@lists.postgresql.org; Tue, 06 Oct 2020 13:33:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1601991227; bh=krqkqKVmPj8knqgq0B8GKNK2/YY5gIvC/D4Wp1PGbFE=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=HRA/WtX9yS6xwM2h5cXSiOAglbpZPQissIP/DlrvM7Mzo0gcybXuuh5EMVuPXmANW N5X6TOfCQ+UGeHZhYrxE1Ejn67y/qmKLoTCw/ZCZhMg0vIQCRHQWCjAIeCmSQjcQIi M3MaekjWAK9QvkfR13k1w9q3geedOSADmpGemzM8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.1.32.48] ([185.40.248.10]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MNswE-1k1W0h2sy8-00OFxW for ; Tue, 06 Oct 2020 15:33:47 +0200 Subject: Re: How to add partitions to the existing table in PostgreSQL To: pgsql-admin@lists.postgresql.org References: From: Thomas Kellerer Message-ID: Date: Tue, 6 Oct 2020 15:33:46 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:T+EP1LZkpfa1DwKHiFNpPFYw2WR7vZKEUJHhiT8qHPikTmGKP1Y PfcVI35/cbsP4GqWVKpG4piMuzZxI4hHK6U54tlms/qcbIkd8tzeIO1inmjdEkk/rMx6ho1 JFZyEepjnIfIESWTy+MWh1ul+OJyskwPA1g3tGTBoY1eGZnf/u99Z6jpLab8jtH9VzWZLo5 KWJn0NFkgbBu9e1IWkVtw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:xcVm1lu6u5A=:aAxYVQVJdmB0+NBUL1JglU tDX1peI2WODDEC9qYpPHZtNDekKCEtr9VEldbBQvq8p6oSGQBnmGqYEYF/5dqbNHi4BZi3VCm JSNqitc5ZUI40W3tHVjQ4XeNYOuOQJUhrb/OzoKfTQMCmqlVvpVogJoHApKssTZ8E0bbXJMw4 3ueGrg0Xw9xR/d70KW0N5yWVtlkzvWKFhQ/na96o/hLHkoecyRRtlJZZoLXTiC4DjhMuENKbX oifogGpuIS9/A0QmoWrDcxezj5qK/5v/wkLPOe0zHbo0e4gUCOYBYO2+YJhMZehtVN1VR9Uwb kq27YD60V88PfHQXPuIE1sjy7QLGr/ZdDtDab1fFlv9xCDuCOnRtjdxQqWU3oaJGq/f2l6F9s JfRpw0XXR6VC670ggrw78t/PMn9hjYRZTIJXuAye6rumzIILTnm17T/YwSro0LsYshZd9ARTz cszSWCp6m/1xiM3V7xZXwwTWinXmdhgVCsHZmJ53KUO6YPqrC+S6Sefz8xphRkGqlopWTVIAv X8jeWQgPUUldOqxkqBK2njG4t1Ycdt1p0PFPQNJ0H6G23KsaD6xw08ebVHDXBNFCb/pbxiW5f EnhZ1At2QYs4QFG/j0dAU2n3s5UfWCw282U/n5m8NE+iNaodHly+qpee1LkSZPd37dRg3TklA Ufof1vksDjDhvPwZjkkkC8jQ08mUsbfHVw2UHv+a7vyYkwKNBn5Y2xpMP4eBobQPiGvHPt1XQ qUeXgbshQwbtpg33mpPkjom5ukwertxeY+VS6oNYWl3/HlDBIgKg1XmwcBTdp7FjzO4xE8MFb DEu1OaDdR+vMqAl8jvV+OSz7ifSFsFBMzF4kTs4efBOHf+1bP1ZMlWxqUG2zB+AMn10qMH2YS TZyL9BvlGpQr3ijEPTm1Q6R4iRp+0Tio6pbafjtKqZ6ZMCRF1pNUnwT2Fe2HVevJs1855RcaO j6v3ykEk7YLaRF0gQBgkP9g9oHlUAPwf2O5fCpWGnDhP+7i7GGllkg+gPuJX8ShJBOLSQ/MEz 3XIx7PEgevFM1oL3veIjpId/JKtVDhK91Tfq08da+11XWQJKlxscDLSHeHfeIrh5lPoByPjZn MoVHuV3y4E7j80idsuc606XMoz1MbK4DE3dx/dl8daHwbfBT/HeexuDqdwrIX1n9qWuRNFOju YVcVrWoLdjIsdgDgICk4BzFK50agdlLg4oFG6XSrtHJkpFTluxtiWvcshhGhhtWbhVcgRZY9i /VCOXJtK/m1bX4FoH List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Naveen Kumar schrieb am 06.10.2020 um 08:31: > How to add partitions to the existing table in PostgreSQL > > for ex, below is my table definition: > > CREATE TABLE ot.employee > ( > =C2=A0 =C2=A0 empno smallint NOT NULL, > =C2=A0 =C2=A0 ename character varying(20), > =C2=A0 =C2=A0 job character varying(20), > =C2=A0 =C2=A0 deptno smallint > ) > > Now I would like to add partition to deptno column > > I don't see any alter table command to add the partition to the existing= table. I seriously doubt a table named "employee" needs partitioning. Partitioning serves essentially two purposes: 1) quickly delete large amount of data (millions of rows) by simply droppi= ng a partition (I highly doubt this is a use case for a table named employ= ee). 2) Improve performance if all queries (or nearly all) include the partitio= ning key in their WHERE clause and thus only a fraction of the table needs= to be read - but this only shows an effect if we are talking about millio= ns or tens of millions of rows. Again something I doubt would be necessary= for a table named employee. And all queries that do not include the parti= tioning key will be slower on the partitioned table! What problem are you trying to solve by partitioining that table? Thomas