Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGEQI-00085l-HB for pgsql-general@arkaria.postgresql.org; Tue, 16 Apr 2019 03:06:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hGEQH-0002bQ-9V for pgsql-general@arkaria.postgresql.org; Tue, 16 Apr 2019 03:06:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGEQG-0002bJ-Sp for pgsql-general@lists.postgresql.org; Tue, 16 Apr 2019 03:06:13 +0000 Received: from mail-yw1-xc33.google.com ([2607:f8b0:4864:20::c33]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGEQE-0007tI-B7 for pgsql-general@postgresql.org; Tue, 16 Apr 2019 03:06:11 +0000 Received: by mail-yw1-xc33.google.com with SMTP id l15so6795300ywe.8 for ; Mon, 15 Apr 2019 20:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=mRoXfUWbOIwsFTJLGgMc3LJyg5XtzC1Gtt7rIas80wM=; b=Qjor3gwUyVc7622u4WznwDBKEZ2C9poTigvNsJcIGghPMfBrFdKSjkR/iBdW2FmV0f e/gvHoCu/sdAZwvYhUurDm2dAaZrmfqfkYokC84UJfk5XU6vwYDUhQMp2VZCVDLMZ5+U mIfNEOAzj2nAXyRTyOBdJFkQJBVQgUWSqJ9afCm82ZJaogFDZE0qUUeeI24pJkNwROLa q35gKC6jqOjLufAz0Dz0V1qQGJVO5oXigHCh73SJ/lSIaGJEOqeO43mvkUoSR8zhMsHT FGWFATPThS1DemNrbDvfHEumx8QAPcISy9nKUE7zUtZ+jYgWgYqR82PVMssqJokUTmje iPVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=mRoXfUWbOIwsFTJLGgMc3LJyg5XtzC1Gtt7rIas80wM=; b=ArjfqhVlYirX33LQRF7VCoW2ZFe9kcNsf/9mE0U1Qurmz+MV9Lg0FUIqvE7v2oLPDn IXaHEBi9qC1/YbMkohbyDqGqdZmJiw9At+HNXb02lrXuEv4/FyYXk+e7wq4OSOHt1joj D5dxrnKcQPzN3s3+dUuQRHm/eGc/0WsbJ349rpX31aTDMXOdFtG2hXrP1j1iQF/HMK/n GGKCkFbhFzRBIQD3+QIcYx9U83T5nSOfJnp4QC3JfetswaMWhYX1un+f3KbXhV2EYqsK uw1+Xj48qCkxCflGw5G04+y4JXlA1Sxf0Zbv1F5fGUJGxji6Vc8sDS6v2Xu8oY65XOyI BpKw== X-Gm-Message-State: APjAAAVC48pI8X0b0nMGCo7tkcuv4AWZjJvSk1L9KcpWJiE3P3elYOBn TgcOSivYq2rUABPBuMVSbjDR8S4cCu8= X-Google-Smtp-Source: APXvYqyIhgHUVeRYbe23LBMf3WsrXBTcWAZQ8N3euorWt7czth56wbGaqP+8JzxBZE4RqwdsZkWP7g== X-Received: by 2002:a81:3a82:: with SMTP id h124mr63237418ywa.263.1555383969400; Mon, 15 Apr 2019 20:06:09 -0700 (PDT) Received: from [192.168.43.92] ([182.0.169.141]) by smtp.gmail.com with ESMTPSA id c184sm6040638ywc.33.2019.04.15.20.06.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Apr 2019 20:06:08 -0700 (PDT) From: Soni To: pgsql-general@postgresql.org Subject: Re: PG10 declarative partitioning that allow null value References: <41964f36-ae96-f37c-edde-bcea231617b3@gmail.com> Message-ID: <9d9f18f2-bd18-ce97-8189-753097515331@gmail.com> Date: Tue, 16 Apr 2019 10:06:07 +0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <41964f36-ae96-f37c-edde-bcea231617b3@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I think it's better to had list partitioning of true/false based on (int_key_column is null) CREATE TABLE partitioned_table_name (like table_name) partition by list ((int_key_column is null)); On 16/04/2019 9:37, Soni wrote: > Hello All, > currently we are planning to migrate inheritance partitioning to > declarative partitioning by range values of int on pg10. But the key > values can contain null. I know that range partitioning does not allow > null values. > We are looking for workaround for this, that is create a list > partitioning and then followed by range sub-partitioning. List > partitioning of number of digits of the int key column. > > > CREATE TABLE partitioned_table_name (like table_name) partition by > list (floor(log(int_key_column)+1)); > > create table partitions_1 partition of partitioned_table_name for > values in (null); > create table partitions_2 partition of partitioned_table_name for > values in (1); > ..... > ..... > create table partitions_2 partition of partitioned_table_name for > values in (9) partition by range(int_key_column); > > Question is : > is this a good practice ? will performance dropped significantly due > to the process of counting the number of digits ? > or is there any better workaround for this ? > > Thanks, > > Soni. >