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 1n9JhH-0001ol-55 for pgsql-admin@arkaria.postgresql.org; Mon, 17 Jan 2022 04:32:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n9JhF-0002nR-T6 for pgsql-admin@arkaria.postgresql.org; Mon, 17 Jan 2022 04:32:45 +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 1n9JhF-0002nI-HL for pgsql-admin@lists.postgresql.org; Mon, 17 Jan 2022 04:32:45 +0000 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n9JhA-0003EJ-8s for pgsql-admin@lists.postgresql.org; Mon, 17 Jan 2022 04:32:44 +0000 Received: by mail-ot1-x32a.google.com with SMTP id 60-20020a9d0142000000b0059103eb18d4so18341794otu.2 for ; Sun, 16 Jan 2022 20:32:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=EDW1Q7+93bsAe1NCw0L5uLdyOUwzjiF5LxAv0CCUtbQ=; b=qYLw6mQwMByyvHd3ycH3tcLA7siF1odXK669L3HMmC1k45BTmAEzR4VdSeNS6cYacG 31UinSsro8mG5EfAVGOxn/OWozfTmimb7ZrEs+r23V3XUlRzmcXTojNVy/Ijrlq7AtK8 3qVrMeND0fdBfvVf1dTLHWhbEPxetYwQH5VKfjYwRTmDlwsscFxyn61mBzypRFoArF11 ouVkGnyC/xy9pxBlu7tAqgkz1Mce0CWqTgIfcfuzWXlWKN0K3vtqqMbNQO1KK/4iQIRV sgc0MPcr9MQMVzjC8aXb0gOJcuUn9mgXk1dRTUpjtynwAUUT47zBwDMuEtHTCQ+ru0Yi upGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=EDW1Q7+93bsAe1NCw0L5uLdyOUwzjiF5LxAv0CCUtbQ=; b=kOzjAPfkXTCUOYw41wGD/94bVzrN3KF8CSAEUG8H605FtUi/O8j9jGOVmBS/slrQVq AHOxFRPmA7ir4t+74slxBVQHCcuWZ8/fMI7Kzv5LHzTJuM4+Jq6wDUDDbUAnok/jP6Zt mBA3bPe/wFaGgqapzWCE7K24DcUeH7J/eTGwrkArMSk7DNlNle7o3Y2svHCPjRXFKRNb hrAS9SuYdrT+nwo8BkXAUIUz/ss3qiUwb6Uihl74is3WOOrWLml0T4gCz5l15PssVpt2 qLfh4ndavDU4AiO8U9i4D6tvfMvgX23Hx7BDqd1Rv41bU6G4IoPPWS3wCLsqiFo61ulP 6i3w== X-Gm-Message-State: AOAM530vMnRwEd7U4lbTRIqTwQ6BMPtUcXwh1Fny8Jyf1dbdD0wW1V/d FaWvbQuTQLMXHfjKHp1hRutfddUsi44= X-Google-Smtp-Source: ABdhPJxPNwD8WNKHHdo30zhM7pDb+cBisgFtpOiMRcI7vWwWFyAAt0h5hvt12ZEuiTnJjeXK7nua6Q== X-Received: by 2002:a9d:19e8:: with SMTP id k95mr14888278otk.12.1642393959432; Sun, 16 Jan 2022 20:32:39 -0800 (PST) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id b26sm5039789oob.10.2022.01.16.20.32.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Jan 2022 20:32:38 -0800 (PST) Subject: Re: Large number of partitions of a table To: pgsql-admin@lists.postgresql.org References: From: Ron Message-ID: <2bdcb53c-c1a2-1813-befe-c51381836bd3@gmail.com> Date: Sun, 16 Jan 2022 22:32:38 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------B7329643CF3D9938ACBF9FC7" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------B7329643CF3D9938ACBF9FC7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 1/16/22 8:44 PM, Victor Sudakov wrote: > Dear Colleagues, > > Do you have success (or disaster) stories for having a large number of > partitions in a table (like maybe 10000) in a production database? > > I've found a great article > https://www.depesz.com/2021/01/17/are-there-limits-to-partition-counts/ > and basically it says 70000 partitions are OK but would like to hear > more opinions especially from production experience. > > If a table itself has e.g. 50 indexes, partitioning it will create 10000 > extra tables and 50*10000=500000 indexes, isn't it a heavy burden on the > system catalogs (pg_statistic etc). It may slow down ANALYZE My experience is with range partitions on v12. It will *speed up* ANALYZE and VACUUM, since those operations are performed against the (smaller) child tables, not the (empty) parent table.  If the table is partitioned chronologically and the older children never get modified, you won't need to analyze or vacuum them at all. > or have some other adverse effects. Queries can easily be *much much slower* if the partition key is *not* in the WHERE clause. -- Angular momentum makes the world go 'round. --------------B7329643CF3D9938ACBF9FC7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 1/16/22 8:44 PM, Victor Sudakov wrote:
Dear Colleagues,

Do you have success (or disaster) stories for having a large number of
partitions in a table (like maybe 10000) in a production database?

I've found a great article
https://www.depesz.com/2021/01/17/are-there-limits-to-partition-counts/
and basically it says 70000 partitions are OK but would like to hear
more opinions especially from production experience.

If a table itself has e.g. 50 indexes, partitioning it will create 10000
extra tables and 50*10000=500000 indexes, isn't it a heavy burden on the
system catalogs (pg_statistic etc). It may slow down ANALYZE 

My experience is with range partitions on v12.

It will speed up ANALYZE and VACUUM, since those operations are performed against the (smaller) child tables, not the (empty) parent table.  If the table is partitioned chronologically and the older children never get modified, you won't need to analyze or vacuum them at all.

or have some other adverse effects.

Queries can easily be much much slower if the partition key is not in the WHERE clause.

--
Angular momentum makes the world go 'round.
--------------B7329643CF3D9938ACBF9FC7--