Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rfpCY-002XZP-NU for pgsql-general@arkaria.postgresql.org; Thu, 29 Feb 2024 22:48:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rfpCX-009EXI-B9 for pgsql-general@arkaria.postgresql.org; Thu, 29 Feb 2024 22:48:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rfpCX-009EX7-02 for pgsql-general@lists.postgresql.org; Thu, 29 Feb 2024 22:48:29 +0000 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rfpCU-0029rq-CB for pgsql-general@postgresql.org; Thu, 29 Feb 2024 22:48:28 +0000 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3c1bfc9a35eso791002b6e.2 for ; Thu, 29 Feb 2024 14:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709246904; x=1709851704; darn=postgresql.org; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :from:to:cc:subject:date:message-id:reply-to; bh=bja9QmPiWZ0SW68++WSILbsDtY0HO7rFaPbDWBnvOr8=; b=ZoI6eG1XXtq+o1H41zs0S5pRpwCjzUfF6WOsudVpaCKh2565q+h9VNx7f2lgZedl63 EZckzYHJd6+VIMDrHJVWOdsxz66TrrY7Bfz39GB0lUrHd6ziaw7urVU1Dl/W8ElzJgpg dZcXrGIJcnbXycm6ncuaNyXvvEYtR9+ZuXSB0kz7owTmpJYdumGy0Q1Poom+MkjtA+0c V7NQPd9nyoZLyji/eOqs4xHohL4uB2a01bf0mdBj/4amnmVbjkrEViLPm5FPqGQUCMZR vAQDv6LDj0VrO67b0jgWmDEMB6vzJsbA924NPVpSxnZv8096UFjp4yF7xSZjiVOKmCp2 192w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709246904; x=1709851704; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bja9QmPiWZ0SW68++WSILbsDtY0HO7rFaPbDWBnvOr8=; b=Etx3WAIOGqT59Z7vaJblbTUDhJNej/RgJysCxNzgRPuHjiZU9cCrKBI78s4LBZuJjx grtAvfor2dLTUdVGfr1PPFrEJYfIdoOpow5kUeo1L0dCDh3+GM/IlClJFqJyjFxHkIIH lN6UXn3a5Z+BITAlzx1e2LAjhCo3RNSZyhKBX2YkVAPEoVPO4GYx0ZHIoohImC59XNcX pv7n+H6ZxI/HKVmDjXQ6rmU9PorXF/2yKpQCCtQI3cc28kkNIcIHcR43D2/KKzkv8wFl TXdBiIBbRWPqqIL7Mrxkzujm1p7TnPWty2fIr74XpHn7ELG1efaPhBoMyNp3aR2gU+DM GDVA== X-Gm-Message-State: AOJu0Yy+H62P8n9gLCN8dGZPUahnbXUf72MCuWpVk9lmz+wxIvGhFr+7 z+i+YACgFmyHAZ9LHoMNeXFCQApMC6r2e6yjg/kQK9zwBrENMVK0Yvt72w9j X-Google-Smtp-Source: AGHT+IGOrgNhh/FSA+YL9WS/uWfz4ypN0CH7AnXyPJr3r3iOd5HARH4bAiyhO45FKMF+9RlKRE57ww== X-Received: by 2002:a05:6871:3413:b0:220:8c78:32e8 with SMTP id nh19-20020a056871341300b002208c7832e8mr3838794oac.45.1709246904464; Thu, 29 Feb 2024 14:48:24 -0800 (PST) Received: from smtpclient.apple ([2600:8801:8600:631::a]) by smtp.gmail.com with ESMTPSA id y39-20020a056a00182700b006e58920c572sm1776433pfa.128.2024.02.29.14.48.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Feb 2024 14:48:23 -0800 (PST) From: Guyren Howe Content-Type: multipart/alternative; boundary="Apple-Mail=_C4043AC7-90DD-4644-9AAC-525890264F12" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\)) Subject: Re: Content for talk on Postgres Type System at PostgresConf Date: Thu, 29 Feb 2024 14:47:57 -0800 References: To: Postgres General In-Reply-To: Message-Id: <05C34416-A3DE-42CC-A95E-B1FD268D6574@gmail.com> X-Mailer: Apple Mail (2.3774.300.61.1.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_C4043AC7-90DD-4644-9AAC-525890264F12 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 28 Feb 2024, at 17:08, Guyren Howe wrote: >=20 > I am to talk about Postgres=E2=80=99s type system at PGConf: >=20 > = https://postgresconf.org/conferences/2024/program/proposals/postgres-s-typ= e-system >=20 > I picked the issue because I think it=E2=80=99s poorly understood, = greatly under-discussed, and an excellent way to empower postgres users. >=20 > I am reasonably conversant with the issue. I=E2=80=99m not looking for = others to write the talk for me, but in order to make the best talk I = can, I=E2=80=99m asking: >=20 > What would you want to see in such a talk? >=20 > I=E2=80=99m planning on covering: >=20 > - The built-in types that are underused and their advantages (eg inet) > - domains > - such things as details of arrays including multidimensional arrays > - user-defined types, their relationship to tables, and generally how = to use them >=20 > I would spend most of the time discussing ways to make effective use = of types. Some examples: > - defining functions of rows so the table can be used kind of like a = set of objects (including the dot notation for invoking functions) > - using UDFs to make code clearer eg if you have an idiosyncratic = functional index, define it using a function of the row, so it=E2=80=99s = easy to get right when querying > - using UDFs as a kind of better domain. eg differentiating imperial = from metric units by requiring an explicit constructor, not just = accepting any old number >=20 > I would mention enumerated types, although I=E2=80=99m inclined to = advise that their inflexibility (eg can=E2=80=99t delete or rearrange = them) means that a related table is probably better (I=E2=80=99d be = delighted to be proved wrong). >=20 > Custom Range Types are an interesting feature, but I can=E2=80=99t = think of a good use case. Any good examples? >=20 > Automatic casting is a feature I=E2=80=99m aware of, but I=E2=80=99d = be interested in any cool use cases. >=20 >=20 > Anything I=E2=80=99m missing? Any existing good discussions of the = subject? Any gotchas about user defined types or arrays? I was only planning on = discussing simple user defined types, without going into writing the = optional features in C. What is worth saying about custom range types? What even would be a good = use case? A range of strings or ip address ranges, something like that, = I suppose? Is there a good case for enumerations versus a fk to a table? I guess if = you=E2=80=99re sure you won=E2=80=99t need to change the values in the = enumeration? Days of the week, that sort of thing.= --Apple-Mail=_C4043AC7-90DD-4644-9AAC-525890264F12 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 On 28 Feb = 2024, at 17:08, Guyren Howe <guyren@gmail.com> = wrote:

I = am to talk about Postgres=E2=80=99s type system at = PGConf:


I picked the = issue because I think it=E2=80=99s poorly understood, greatly = under-discussed, and an excellent way to empower postgres = users.

I am reasonably conversant with the = issue. I=E2=80=99m not looking for others to write the talk for me, but = in order to make the best talk I can, I=E2=80=99m = asking:

What would you want to see in such a = talk?

I=E2=80=99m planning on = covering:

- The built-in types that are = underused and their advantages (eg inet)
- domains
- = such things as details of arrays including multidimensional = arrays
- user-defined types, their relationship to tables, and = generally how to use them

I would spend most of = the time discussing ways to make effective use of types. Some = examples:
- defining functions of rows so the table can be = used kind of like a set of objects (including the dot notation for = invoking functions)
- using UDFs to make code clearer eg if = you have an idiosyncratic functional index, define it using a function = of the row, so it=E2=80=99s easy to get right when querying
- = using UDFs as a kind of better domain. eg differentiating imperial from = metric units by requiring an explicit constructor, not just accepting = any old number

I would mention enumerated = types, although I=E2=80=99m inclined to advise that their inflexibility = (eg can=E2=80=99t delete or rearrange them) means that a related table = is probably better (I=E2=80=99d be delighted to be proved = wrong).

Custom Range Types are an interesting = feature, but I can=E2=80=99t think of a good use case. Any good = examples?

Automatic casting is a feature I=E2=80=99= m aware of, but I=E2=80=99d be interested in any cool use = cases.


Anything I=E2=80=99m = missing? Any existing good discussions of the = subject?

Any gotchas about = user defined types or arrays? I was only planning on discussing simple = user defined types, without going into writing the optional features in = C.

What is worth saying about custom range = types? What even would be a good use case? A range of strings or ip = address ranges, something like that, I = suppose?

Is there a good case for enumerations = versus a fk to a table? I guess if you=E2=80=99re sure you won=E2=80=99t = need to change the values in the enumeration? Days of the week, that = sort of thing.
= --Apple-Mail=_C4043AC7-90DD-4644-9AAC-525890264F12--