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 1mNVAH-0005EO-Si for pgsql-general@arkaria.postgresql.org; Tue, 07 Sep 2021 07:05:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mNVAF-000421-Oq for pgsql-general@arkaria.postgresql.org; Tue, 07 Sep 2021 07:05:03 +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 1mNSNl-0006Bu-9x for pgsql-general@lists.postgresql.org; Tue, 07 Sep 2021 04:06:49 +0000 Received: from mail-sy4aus01on2091.outbound.protection.outlook.com ([40.107.107.91] helo=AUS01-SY4-obe.outbound.protection.outlook.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mNSNh-0002ps-Vf for pgsql-general@postgresql.org; Tue, 07 Sep 2021 04:06:48 +0000 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=nwHmpY9fjU9mhtA/0JnaFPm/kKDjxbYDccVV+NEiSfBN8vMEAziilIwR8YqifMajT+x/ja6Xe2DgusEroAq7fZYIM7QwFJHEf2BgUtB6/ZXrPB23bkoWuGJtsddx7PmrBLDmhKgNWqlN16CZ7SMv3Pe1rjhf9PMe7PTOZdMW99XhUtsThIMnXDN0P5EI1x3HNtdqOICfhsxd37ruloepmEXpOO3ddHfpVM0yMcNQCd7ZFVNNQzBqygY44YdUJ13lYvI86QsHqC8rJLS12X7lQgKt2raerU6vODAEQzZtxBjFw2BrYSQBGg6Dsv2fa/guV0owGvDMvoaA4q8WBRM/Ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Y5wU2yGWQVDs5q9BwUQBkWjUwzBviVHDQ3LJfbWuvok=; b=DOGgpRJWs4+RCYHkMeDcY91Ib1XTYnzMdlxIQXi5R/MEOqtC+eUu8y1dxQwdXvqTVQ4krBTXYUuS+HknK0DxZrKz75DCtgKiuWaObY9aqNMk8hi5/g6pt82cDtvKNCTEm1pFL9JcTqSvajRAQRcDqPYHittQLoIHqVZgL4F+wkF6R5lGLLrD1FLrGfGxfTp2b93/edbIaZ4e6maPviBnBQ6SmrNMXr6SW+ucbmU9G7JsJh5eZNbwSCVRIkR60Sf0ykIbVfTPuiWxwlVzXjDeDYAH61z1Ddzi9madKqrmQwpqCQkxAtf77+sZ0n8+TOU2SHLl43HQgMyFdzjI68jpsQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 104.47.71.241) smtp.rcpttodomain=gmail.com smtp.mailfrom=niwa.co.nz; dmarc=bestguesspass action=none header.from=niwa.co.nz; dkim=pass (signature was verified) header.d=niwa.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=niwa.co.nz] dkim=[1,1,header.d=niwa.co.nz] dmarc=[1,1,header.from=niwa.co.nz]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niwa.onmicrosoft.com; s=selector1-niwa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y5wU2yGWQVDs5q9BwUQBkWjUwzBviVHDQ3LJfbWuvok=; b=pVAp2V9fga2uNdBChvbA5f4Ekxq1/h05NcwpA7c4Sf+PbddEo8WAVZtmb/zClAWApR6E++wBUEvoPMy4f14PDY9gY0eFnbAr4qpbE9pe9Xk7wG694nYvjibq88/Grn1twc5LwCnv9+5DJ/LoerGs7KpwnLlQG/i/xbRyJoFlB6Y= Received: from SYBPR01CA0185.ausprd01.prod.outlook.com (2603:10c6:10:52::29) by MEAPR01MB3239.ausprd01.prod.outlook.com (2603:10c6:201:32::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Tue, 7 Sep 2021 04:06:35 +0000 Received: from SY4AUS01FT011.eop-AUS01.prod.protection.outlook.com (2603:10c6:10:52:cafe::ac) by SYBPR01CA0185.outlook.office365.com (2603:10c6:10:52::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Tue, 7 Sep 2021 04:06:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 104.47.71.241) smtp.mailfrom=niwa.co.nz; gmail.com; dkim=pass (signature was verified) header.d=niwa.onmicrosoft.com;gmail.com; dmarc=bestguesspass action=none header.from=niwa.co.nz; Received-SPF: Pass (protection.outlook.com: domain of niwa.co.nz designates 104.47.71.241 as permitted sender) receiver=protection.outlook.com; client-ip=104.47.71.241; helo=AUS01-ME3-obe.outbound.protection.outlook.com; Received: from hamlmail.niwa.co.nz (103.229.249.34) by SY4AUS01FT011.mail.protection.outlook.com (10.114.156.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Tue, 7 Sep 2021 04:06:34 +0000 Received: from AUS01-ME3-obe.outbound.protection.outlook.com (mail-me3aus01lp2241.outbound.protection.outlook.com [104.47.71.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "DigiCert Cloud Services CA-1" (not verified)) by hamlmail.niwa.co.nz (Postfix) with ESMTPS id B2E82603828; Tue, 7 Sep 2021 16:06:33 +1200 (NZST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SAD6TZOLkn4zCUF6jNUYvc7ftz0MuUIhnLyBcwXPYdi1ZiVyjE2TIu0sLWAQEYIocFtHtFgjQagzpr7SYvP/KC5u9dnhlHeRudAl5499MPW1+hzJ39d60v31AjchG3rd4aLV4FkQYqZSD2XwQ4oIh83aRLQlwG9nwLHAgKP2Jl8J8fuzQeeQFlL4fiRQwekxBwZooA3vrcwAYWlBSNypLQIT5A0gNtQEt/kCcuE1poekRYIFhZmhxIxi06lwT1cQ9CKz+qT+5s3r7J+33YPUN1JN1RlD/+DzwN824DlDxUl4372p8FvIkAzR7b0nDHrErEzMuSYKlwdccVNJGmzFqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Y5wU2yGWQVDs5q9BwUQBkWjUwzBviVHDQ3LJfbWuvok=; b=ntbJ4ZKffVGT+vjAUUMqrJBoqp3BXNAeD1TUWaD7O2Op8ScaZ1S4tagtrXsAMj427yCX/FFI9WHuaJqQH22HbUim6ant4RhQhdwe7ZZOhv3E2PBFIh5PgkQicAztONFH1ziG6qPf7JKB2emQLuDn4Uu4BpZjhSD47UgChHf5NvTZ//UgVESdwY9LvA/OA6Fh9irEpvESIrp/kpgavYJSGyF8KvFfOjAANPVtGB94GOlkKoUg/pY7HxHEp4qkbElOQCbDu5vTO7hLCjXa95jOUOHqPBMjhUeto5/2vjtS9b3/RdYd0p90uq0Re2O9c2xGEgMFS+V6dBQhp8JdRzdOeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=niwa.co.nz; dmarc=pass action=none header.from=niwa.co.nz; dkim=pass header.d=niwa.co.nz; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niwa.onmicrosoft.com; s=selector1-niwa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y5wU2yGWQVDs5q9BwUQBkWjUwzBviVHDQ3LJfbWuvok=; b=pVAp2V9fga2uNdBChvbA5f4Ekxq1/h05NcwpA7c4Sf+PbddEo8WAVZtmb/zClAWApR6E++wBUEvoPMy4f14PDY9gY0eFnbAr4qpbE9pe9Xk7wG694nYvjibq88/Grn1twc5LwCnv9+5DJ/LoerGs7KpwnLlQG/i/xbRyJoFlB6Y= Received: from SY4PR01MB7076.ausprd01.prod.outlook.com (2603:10c6:10:145::5) by SY4PR01MB5753.ausprd01.prod.outlook.com (2603:10c6:10:ff::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17; Tue, 7 Sep 2021 04:06:28 +0000 Received: from SY4PR01MB7076.ausprd01.prod.outlook.com ([fe80::b50d:ac75:349e:7542]) by SY4PR01MB7076.ausprd01.prod.outlook.com ([fe80::b50d:ac75:349e:7542%9]) with mapi id 15.20.4478.025; Tue, 7 Sep 2021 04:06:27 +0000 From: Brent Wood To: Tim Uckun , pgsql-general Subject: Re: Choosing an index on partitioned tables. Thread-Topic: Choosing an index on partitioned tables. Thread-Index: AQHXo5rApSbZKRbvUEulC9U/emVSKKuX8w51 Date: Tue, 7 Sep 2021 04:06:27 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=niwa.co.nz; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 085d9df8-f700-4891-77bf-08d971b4e1ce x-ms-traffictypediagnostic: SY4PR01MB5753:|MEAPR01MB3239: X-Microsoft-Antispam-PRVS: x-niwa-seemail: Out x-ms-oob-tlc-oobclassifiers: OLM:8882;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: bA/qI6T5N9e5YAeg/CW2vIasrE97swmeW2TzQ1WoblqpGzoforQnWUV4AJmSrY6i05jRU6vjfT/uHi7LLj9ZjPEo7OV1DCyx8xmuRM+rravPcJf0RmjQAa0YLqq9J9JoxnPck1c5vgLFoEPj1GvPucFarezOE0ORP4ni282yjI8rSpGGyw9XP2naLSGaIbNRC/ULGIMcxhjZ5TwmQdei8e2VRuNuOJSpsYhh62PD58F3XVV1v+Us1+Bsg0/3pRSNs/FvNO8ZWCX8LpS4HXAyuWJj2/ctiWTJCGYBku+ghhq0QTYTmAnyAPbeN+1wK0E9za+t18XJMT1WitOyII++u4Yg5UMQDRKnsjj3rAzlXzSnekJyUnkKz0DFCsHOzKr8ZSExZFD7M35IZEdeov5CeeAZFGzwJj3OnMW8BeZ5+1a2x6qAhj0ekCBt9IzkhVCzlqCVnWMNPZ/DsZLdNDhrMZ7IQVKAu1pQktAVBMCCqgbqt5uuQX2VwP9kJrl1/vmeTN5q5v3a/Hxh1q50oXfs6Qeo+hrwD/vu2+TIy3rDxLR7x47lLC7dJ5icOvL8TSWpg/kHyJmgvkVDLMOUc1pRx+VqteRhhabRYnb3X0lft8FFIuey8svnvwsc/i8emgGiJzpW1+kZvQTXthjB8msrm65rmVylsKrcPAi9mxHJbjMmKd03ycth2xpfep6YQW9azJ1TKiGqlHjfEgBgBjMvkf/E7gpHp1SL2V3Uu/MRuDm1ruicSEaDJo7sAjbSFEZ0qHT1hUShtZEjaVAZ8GKlqeXiCLmdahdRyF2kRqP8/mw= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SY4PR01MB7076.ausprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(396003)(346002)(39860400002)(2906002)(8936002)(7696005)(71200400001)(8676002)(19627405001)(86362001)(38100700002)(52536014)(38070700005)(5660300002)(122000001)(6506007)(45080400002)(66556008)(66946007)(53546011)(33656002)(83380400001)(76116006)(64756008)(186003)(66476007)(55016002)(66446008)(9686003)(110136005)(966005)(166002)(478600001)(316002);DIR:OUT;SFP:1102; x-ms-exchange-transport-forked: True Content-Type: multipart/alternative; boundary="_000_SY4PR01MB70766A066A6ED013BA6E83E7A1D39SY4PR01MB7076ausp_" MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY4PR01MB5753 X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[104.47.71.241];domain=AUS01-ME3-obe.outbound.protection.outlook.com X-MS-Exchange-ExternalOriginalInternetSender: ip=[104.47.71.241];domain=AUS01-ME3-obe.outbound.protection.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: SY4AUS01FT011.eop-AUS01.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 206e2a71-6687-47b3-4e95-08d971b4ddaf X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P57cAGN9vkNRUpIyp+/4lO4t4njZ8efBrsKzrvQ/Vk1S4Swh/BIMe91JldofEUh7/rWpxEf7CG8i9xRfZBszPwzsU2IMfWWShr3znUtHuD9wVl75XLMTskwTnD0iaGwZqFsMlMRLls7Ea0dL8R2jQ3H1kUxM5gayIKT8QUq3HZtuj/RRXd5aBQBy+A9/hAJmFDqQiRjqphln4PPYaLAJhP9/CxJk0iYyLHC7KDMyXaq+o1CAAOpMPzDYGWVWo6VxGpCb/ImZMKiJ039pSD8z6KiFwjexBkOdzpKNiVD4y0aay0K5RZpFg+YTkCUrduBLlV+Un3RqaNJS4sdOiRvCXCPE7rdR74cR4mQGZ7JahVcb4RQEAU4/CfCsiZ8c6Jlek86RGGgdfChQwDTI5+N8YTD0umlp9eXsMpN/K1W3cxQIYUy/Hv1JuZpB5OFNZaMftXQ2kgA8moBeY+nl/FL+gQcWiZhkWgQm4gyTUw2Br7rFCoaGxoTO5T9mxuK3W+RG4MP/JXu0wu9aiqCSO5p6e/LbfQwpfzg/c09bnB2B/3srNvYqyR+I4QBWM31bsRNt84nO1v/UC27Vf61SH9BMllWvqB0qbHyyOZc+tW1K0GIVkCaqP2o/5oLhCo0fNUWaS49idxpNX8f/UOKHpuFgar2D5fERT6lR40jFZgEn1eHdbpBgQHp8vVLXjhAAReK0fTzrAN6j2wLPRB1RfNgVRFEVy+5u71Kche0sRhIsRVySJpxxBZ9WZcMn7yMVgltCturpeAv8bGE2x4bnfH6sauH+65BI0Lz2SDDsW1e1ErhkHoItA+2P7P4ty/nL0WuoMJPWpl1agjHu7Vyf/ZuvAGQT+71K0E7yNbrrwA78FlE8tbtopJ42teQtW4+F0e7TuJaqzrzNAPji1Xva6MoXxwQSo/t0ZrZ9fpNcsUiewRk= X-Forefront-Antispam-Report: CIP:103.229.249.34;CTRY:AU;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AUS01-ME3-obe.outbound.protection.outlook.com;PTR:mail-me3aus01lp2241.outbound.protection.outlook.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(186003)(508600001)(32850700003)(5660300002)(110136005)(26005)(45080400002)(166002)(83380400001)(33656002)(9686003)(316002)(36906005)(82310400003)(86362001)(156005)(53546011)(6506007)(2906002)(7696005)(55016002)(47076005)(8676002)(8936002)(70206006)(7636003)(70586007)(966005)(19627405001)(52536014)(336012)(36860700001);DIR:OUT;SFP:1102; X-OriginatorOrg: niwa.co.nz X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2021 04:06:34.4793 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 085d9df8-f700-4891-77bf-08d971b4e1ce X-MS-Exchange-CrossTenant-Id: 41caed73-6a0c-468a-ba49-9ff6aafd1c77 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=41caed73-6a0c-468a-ba49-9ff6aafd1c77;Ip=[103.229.249.34];Helo=[hamlmail.niwa.co.nz] X-MS-Exchange-CrossTenant-AuthSource: SY4AUS01FT011.eop-AUS01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MEAPR01MB3239 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_SY4PR01MB70766A066A6ED013BA6E83E7A1D39SY4PR01MB7076ausp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Tim, I've had good success with TimescaleDB for large timesries databases (40b r= eadings). https://www.timescale.com/ You turn your timestamp table into a Timescale hypertable and it looks afte= r the indexing and partitioning automatically, with the table accessed like= a normal postgres table, but very quickly. It also adds some SQL functions to add a bit of time based query functional= ity. Cheers Brent Wood Principal Technician, Fisheries NIWA DDI: +64 (4) 3860529 ________________________________ From: Tim Uckun Sent: Tuesday, September 7, 2021 15:44 To: pgsql-general Subject: Choosing an index on partitioned tables. I have a series of tables which are going to be queries mostly on two columns. A timestamp table and a metric type column. My plan is to partition by date ranges which means the primary key has to include the timestamp column and the id column As far as I know there is no way to specify an index type for those columns. The metric type is a text column and will not be very selective. It will have somewhere around 200 types of metrics and they will all be short, less than ten characters. Given that there will be a lot of records I was wondering what type of index would be ideal for that column. Seems like hash indexes would be ideal because only comparison will be =3D and they are smaller than Btrees but for a while they were not recommended. Would hash be the best or would something work better? [https://www.niwa.co.nz/static/niwa-2018-horizontal-180.png] Brent Wood Principal Technician - GIS and Spatial Data Management Programme Leader - Environmental Information Delivery +64-4-386-0529 National Institute of Water & Atmospheric Research Ltd (NIWA) 301 Evans Bay Parade Hataitai Wellington New Zealand Connect with NIWA: niwa.co.nz Facebook LinkedIn Twitte= r Instagram To ensure compliance with legal requirements and to maintain cyber security= standards, NIWA's IT systems are subject to ongoing monitoring, activity l= ogging and auditing. This monitoring and auditing service may be provided b= y third parties. Such third parties can access information transmitted to, = processed by and stored on NIWA's IT systems --_000_SY4PR01MB70766A066A6ED013BA6E83E7A1D39SY4PR01MB7076ausp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi Tim,

I've had good success with TimescaleDB for large timesries databases (40b r= eadings).

You turn your timestamp table into a Timescale hypertable and it looks= after the indexing and partitioning automatically, with the table accessed= like a normal postgres table, but very quickly.

It also adds some SQL functions to add a bit of time based query functional= ity.


Cheers

Brent Wood

Principal Technician, Fisheries
NIWA
DDI:  +64 (4) 3860529


From: Tim Uckun <timuc= kun@gmail.com>
Sent: Tuesday, September 7, 2021 15:44
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Choosing an index on partitioned tables.
 
I have a series of tables which are going to be qu= eries mostly on two
columns. A timestamp table and a metric type column.

My plan is to partition by date ranges which means the primary key has
to include the timestamp column and the id column  As far as I know there is no way to specify an index type for those columns.

The metric type is a text column and will not be very selective. It
will have somewhere around 200 types of metrics and they will all be
short, less than ten characters.

Given that there will be a lot of records I was wondering what type of
index would be ideal for that column. Seems like hash indexes would be
ideal because only comparison will be =3D and they are smaller than
Btrees but for a while they were not recommended.

Would hash be the best or would something work better?


Brent Wood
Principal Technician - GIS and Spatial Data Managem= ent
Programme Leader - Environmental Information Delive= ry
+64-4-386-0529

National Institute of Water & Atmospheric Research Ltd (NIWA)
301 Evans Bay Parade Hataitai Wellington New Zealand
Connect with NIWA: niwa.co.nz= Facebook LinkedIn= Twitter Instagram
To ensure compliance with legal requirement= s and to maintain cyber security standards, NIWA's IT systems are subject t= o ongoing monitoring, activity logging and auditing. This monitoring and au= diting service may be provided by third parties. Such third parties can access information transmitted to, process= ed by and stored on NIWA's IT systems --_000_SY4PR01MB70766A066A6ED013BA6E83E7A1D39SY4PR01MB7076ausp_--