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 1jUshC-0003xU-I1 for pgsql-performance@arkaria.postgresql.org; Sat, 02 May 2020 14:00:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jUshB-0002DY-AP for pgsql-performance@arkaria.postgresql.org; Sat, 02 May 2020 14:00: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 1jUshA-0002Bk-Sl for pgsql-performance@lists.postgresql.org; Sat, 02 May 2020 14:00:45 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jUsh3-0003rs-6Y for pgsql-performance@lists.postgresql.org; Sat, 02 May 2020 14:00:43 +0000 Received: by mail-qt1-x841.google.com with SMTP id 71so10160903qtc.12 for ; Sat, 02 May 2020 07:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bcct28BZVZr8X/o/9XTU2MiJ1hK0K3lO2Exe1Y84tJA=; b=kS3NnPEPY6KCn/JAqeo744tvn2nFE93LA25DRj/C+wvaGrUJ8DqTUo7K7NyVUm635H 69LCnI4ZgBMIHqNKeB8YGN3zbAKwjGky+FzIccgOUs8U6swediD5+3VeDYteEupiCgiZ yBsP5CSzuAXlQRmWQ0rz3SkCFB2bCBBMuzJgu5uwYHkdIlLxqpYfWSm83T4kqVjY3Ul5 H80jqG7l4la2Gjelj5zBGhu0+Qi2xQaLYVu8MsNv2BoxCXW9EMf/wCoury/DonQC5nxS YLwRmImRd+4SPfV1WW+EhaBvnk2Bd8ez+sYou9fhztWOe1HSSJw1COUtIJeacWYzC+9G W28g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bcct28BZVZr8X/o/9XTU2MiJ1hK0K3lO2Exe1Y84tJA=; b=TOwpMQAqKHcT/wIizu24qWZ5cQXlSk1c5JWWzYwHULjVc9Yj6iQl/vuLQcQ1yFRxfH XDO51WrSS1JNICk0OEBERwMjAOgWCgp8tdx5qy6mdj8G45m7+fCqgcdjC3h+FJn7oJIZ 0+g6yz1F4a34KVvFbaK6rn5zHcL29+yLi2wKrAgpsmOlxWKThsuSUap7eqWSYStYcYmY NtZlGXxhwMe7qumJMTjoo8tnSA1UlbRK00pc2F2p5Pu9FNx7MXf+7bQ14eS1PIDDw/39 rxxhbhXeSdSVpKpQ+c4Ofohx04gmXvCuhAlLBjtfBSbv1qhfqp8BrIwrJ9dTH1sMsdQG W5Og== X-Gm-Message-State: AGi0PublYrm5+QlH+4sM/or5Gzrr2U3NSX7WXZU2xlK9aKP9RjmI2gQk YOscNbyxhV61DRFaRfv9xjLkUw== X-Google-Smtp-Source: APiQypLf8TnbUWEkyIKHgtrHgJghRkJYv+6G00q73onPpt2MWmWqD+ek5wg3+LXle4xSL+EWuuF3cA== X-Received: by 2002:ac8:6159:: with SMTP id d25mr8728312qtm.70.1588428035470; Sat, 02 May 2020 07:00:35 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id b126sm5146456qkc.119.2020.05.02.07.00.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 May 2020 07:00:34 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 0516D800A81; Sat, 2 May 2020 09:00:32 -0500 (CDT) Date: Sat, 2 May 2020 09:00:32 -0500 From: Justin Pryzby To: Arya F Cc: pgsql-performance@lists.postgresql.org Subject: Re: Best partition type for billions of addresses Message-ID: <20200502140032.GI28974@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, May 02, 2020 at 09:20:06AM -0400, Arya F wrote: > I need to store about 600 million rows of property addresses across > multiple counties. I need to have partitioning setup on the table as > there will be updates and inserts performed to the table frequently > and I want the queries to have good performance. I dug up the last messages about this: https://www.postgresql.org/message-id/flat/CAFoK1aztep-079Fxmaos6umR8X6m3x1K_aZLGtQGpYxfENh9%3DA%40mail.gmail.com https://www.postgresql.org/message-id/flat/CAFoK1azkv1Z%3DRr7ZWrJjk0RQSoF6ah%2BQMpLSSyBs1KsEiQ3%3Dvw%40mail.gmail.com https://www.postgresql.org/message-id/CAFoK1axr_T6nB8ZAq8g2QBcqv_pE%3DdsZsxyjatz8Q67k1VKAnw%40mail.gmail.com > From what I understand hash partitioning would not be the right > approach in this case, since for each query PostgreSQL has to check > the indexes of all partitions? Indexes are separate from partitioning. Typically, the partitioned columns are indexed, but it's not required. If the partition key isn't used in your typical query, then partitioning didn't help you, and you chose the wrong partition strategy/key. > Would list partitioning be suitable? if I want PostgreSQL to know > which partition the row is it can directly load the relevant index > without having to check other partitions. Should I be including the > partition key in the where clause? It sounds like you're thinking about this backwards. What are your typical queries ? That should determines the partition strategy and key, not the other way around. You should maybe think about whether there are views/functions/joins of the partitioned column. For example, at telsasoft, our report queries *always* say "tbl.start_time >= t1 AND tbl.start_time < t2", so I partitioned our tables BY RANGE(start_time), so a typical report hits only a single table. And, start_time has an index on it, so a typical query over 1-2 days will only hit a fraction of that table. -- Justin