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 1l2hXK-0005se-7B for pgsql-general@arkaria.postgresql.org; Thu, 21 Jan 2021 21:30:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2hXJ-0002bn-60 for pgsql-general@arkaria.postgresql.org; Thu, 21 Jan 2021 21:30:37 +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 1l2hXI-0002be-TT for pgsql-general@lists.postgresql.org; Thu, 21 Jan 2021 21:30:36 +0000 Received: from mout.gmx.net ([212.227.17.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2hXG-0000C7-FE for pgsql-general@lists.postgresql.org; Thu, 21 Jan 2021 21:30:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1611264633; bh=2GQ8KgcTUALhXWg3dXEH7WCHPrp7pqHHjjMhGvburqQ=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=LaN4ST9jOX5ertZh0DDhQbCLR8ZjCHTGK2d21chRv7HW0Q4ZAUEj+YjZQ5hbxLaBM u30OiMB12nu+buV62PgOonBJWmku7vFSfWJqi9mksrASgBBTUq1xnxps8CGSpy8lKL yB/h1KNICNjJ+BnnUC/uKcFVYYlGAjJ+d+l+hOh4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.20] ([83.171.169.210]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MHGCu-1lFqfp05s8-00DEGP for ; Thu, 21 Jan 2021 22:30:33 +0100 Subject: Re: interval data type To: pgsql-general@lists.postgresql.org References: <0c229ba17fe7eb51223ebd8bb90cdfff.squirrel@webmail.harte-lyne.ca> From: Thomas Kellerer Message-ID: <7592ec6a-b3d2-e376-ff16-af03120fcbc8@gmx.net> Date: Thu, 21 Jan 2021 22:30:33 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: <0c229ba17fe7eb51223ebd8bb90cdfff.squirrel@webmail.harte-lyne.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:DQjo8RtucJyL1K7+zHJ0jiMoeCxnyDANhpIsNj56D3q+ltxCzcI 33j9fogs84DBiWFD6sqMp5CZ0Lw4Kh+5XgN1hIJxdQNR5uUAXqkiC/m+CJyNW5j9I0h0x0W sFWGmTdgTus1uy9F6JIti6EEJ0jJE5zKJVChUpp79mI5aWpY38JllEEKBdPFdjLufRKILlF Ezt5ubnpucum+O12ClFCg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:2JHA3X1z0i4=:PQjta4RF8LgiwLlOWNQ2Xm wlMfIiH/KZlBswHEk8ABdTm8ymk3ZUHrkUBYe7iy3OvWiNgDKMfnAoC33UoSh00c99VFElKXp yT9EBkjna1X/wfPRpeKZkV2TVUwfPTdMuTUOXQQHEZfBwOU4QQlX7MYkqZU/BjK5B2K8577Gh tQpfDUp4f5GKP3LRDsoOCgOBReaRijUhaBJ6LXbiiBlrehq8KOnBTLA3V9l+JmZ7pXjWB5+Rk kNCajy9N3/jTpAvT0I19K9YXmMhrbj51L+RcmQeToPhYK97PPOUTVzE088QnzUOq10jTZI9OH lRzFIw6YGiX2aYtHOEb7jggxOU1zT9ksW44rmpJiTtAHNQsdDwc4vofCLyRnXPRl3YmO8GeII 8UPwgrhiGhRPY9Cb8/U4++UOCQ2fUQMbmibyJuWHRXjy8WAZAhj9DEoG6rv4NGfmFt/Z/jyOw xeQCYA2XjQI63c/1l9rtIUvYhpfMJ9Wamo/bU+LUgQ483A1l70b4ygoCT4OzNfOS8O/rnC39p HdsEHkbKXPJWoT+Ec5DmEn+UuqI/XUmiwdLuIhJy1FudD+otVChzU7SPvctjYayN56k5ZIBnE R032VKtXOpuQPWnbsoXHSYfDh3H8DG+3mCPljD0AvbBs1tbEaZXetOygUZXnXVFzm0qP3QaIr 2R5fxSb8IY7Psa1CritXHORPJeib2EzKnYX0psgKNDFrmZigDbrg9PUaMSo0fZIPHcbPyUt/G uJuPCjDiUNy5iqXlhe7CHXAJ0va/OxzWG5dOo59v3a6gXTxL1TPjRXMcuIK9XK5aJ9ZbDlL4y 5L1j8EMkB0zZ5AdR4/QS5p2j2JBK0FmPuOkK4t2KQhmwR+MVBMPeO5gU28+U28igAn7Qy7okS 01aF535rTMK7T3Rp4O4Q== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk James B. Byrne schrieb am 21.01.2021 um 22:22: > What is the difference between interval(3)[] and simply interval(3)? Where in > the documentation is the [] syntax discussed? The [] denotes an array of intervals. So in a column defined as interval[] you can store multiple intervals, just like in an array of text (text[]), where you can store multiple strings. This is discussed in the chapter about arrays: https://www.postgresql.org/docs/current/arrays.html > Also I do not understand under what circumstance one would use the interval > type in place of a simple integer. What would that integer represent? Seconds? Minutes? Hours? Fractional days? Using an interval makes things a lot easier, because you can store any "duration" in it without the need to know what the unit is that is stored in the column. Also timestamp values and intervals go well together, but not timestamps and integers You can add an interval to a timestamp and the result is a new timestamp. If you stored the "duration" as integer, you would first need to convert the integer to an interval.