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 1nIIHu-00013L-4m for pgsql-general@arkaria.postgresql.org; Thu, 10 Feb 2022 22:51:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIIHs-0002gm-J6 for pgsql-general@arkaria.postgresql.org; Thu, 10 Feb 2022 22:51:40 +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 1nIIHs-0002gd-5U for pgsql-general@lists.postgresql.org; Thu, 10 Feb 2022 22:51:40 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nIIHo-0008JH-9w for pgsql-general@lists.postgresql.org; Thu, 10 Feb 2022 22:51:39 +0000 Received: by mail-pj1-x102d.google.com with SMTP id qe15so6477566pjb.3 for ; Thu, 10 Feb 2022 14:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc:message-id:references :to; bh=sqvPA3XLICD09N3s74wxQeVARpis7OU1RyVtw3HtNLQ=; b=KHUcRFMsLlZPed9E9FYsJVkY00UW9cPK+aV6DYFmPZSylcx0Dzr/rOYZ96XH752J2c AzTncQewlDHML+84tYCU/dN0w/V6gfcMHENeKrTaEy28H3PfNI4swYGxuHtmWupBgFgh a5+NVGhLtMn2PGAg0URA++sRhaw9P6DvFT2l5+s9c1ftqjv65M008RYepdMtTkoh8Ujz mCdgkyj7H5hxD5jqAn9KRD1l0Kk3Ft18KkjaTVZT3wGkmSP7bxcGFbEDj/GWXACpjGgd puVAD3euDEL8RXhQVg8CUmYQqmWoaf6pAcUOUIlJwynFeHXxoAy6GantbGVIpOx/WBsJ sfaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=sqvPA3XLICD09N3s74wxQeVARpis7OU1RyVtw3HtNLQ=; b=kw82TD1LlUxJChbEpGgmHmR8spPeYxiMsISnXmm7MuY5xrx0UlJaF3YKspxEIrXtK8 huzazk5ct7D0rJXcrVhOAOEUiTtP1cp4CiifEsKCRbmq4oyI5P8lBTm+IkEatfZ0MnnJ 1T+PqzSyi2tKMHJV7LGaismYSi3L/u5YKuT43N75voxGGBcBWW6B7Pp1Zvf7NknVk2C7 EzzeJ0HMZuGzRmjbakZBpUSKmcBIsLyHEd6yW7B1cpLqiG6UqI7y2pJ8DhsknF5Kgutd g17ytkoIcRoWdOkxJPAF+jx9liKmPMpSyc0E+2dHvcKe4bKJ894OD8pd/epMhpCcWFYx 9Tbw== X-Gm-Message-State: AOAM530D1uAkyqrt/2OFBid3BVZufpWdEQQbt/ygq2HfBOJTu4HY7kHt kTPlbt00MIVK4fTAbzn2FgI= X-Google-Smtp-Source: ABdhPJx0Xlirahu7gnc0wyWkhzUjmpwNB1FVagKSy8p0xY05DOTuyspjbCNTiQCFzPk5OrRZyfdwjQ== X-Received: by 2002:a17:90a:6881:: with SMTP id a1mr5134602pjd.123.1644533493909; Thu, 10 Feb 2022 14:51:33 -0800 (PST) Received: from smtpclient.apple ([2600:8801:8800:2::f]) by smtp.gmail.com with ESMTPSA id mz16sm3301898pjb.53.2022.02.10.14.51.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Feb 2022 14:51:33 -0800 (PST) Content-Type: multipart/alternative; boundary="Apple-Mail=_4708BB79-E1A8-4E8A-ADB3-3EE6440D4EEC" Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\)) Subject: Re: Can we go beyond the standard to make Postgres radically better? From: Guyren Howe In-Reply-To: Date: Thu, 10 Feb 2022 14:51:30 -0800 Cc: Bruce Momjian , "pgsql-general@lists.postgresql.org" X-Mailbutler-Message-Id: 6EA7793A-9784-49FB-A8B8-718A807ED997 Message-Id: <937E9BA7-F8D9-4547-A171-AC1497470A0C@gmail.com> References: <7117322c-185c-4283-990d-6646d8476409@Spark> <20220210172229.4it7ioddvrtmws37@hjp.at> <20220210172545.f7vtdcrg325v3xlx@hjp.at> To: Benedict Holland X-Mailer: Apple Mail (2.3693.60.0.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_4708BB79-E1A8-4E8A-ADB3-3EE6440D4EEC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 When you dig into it, the powerful idea here is the relational algebra, = and its equivalence to a first-orderish logic. I put up with SQL so I can use relations, and I love Postgres because it = has the least bad SQL (by a mile!) But SQL is a terrible, no good, very bad language. I don=E2=80=99t really understand why folks who love the relational = model aren=E2=80=99t perpetually up in arms about SQL being their only = option. Much better query languages are known and well studied. https://www.scattered-thoughts.net/writing/against-sql = I=E2=80=99d love to see Postgres offer say Datalog. But until that = Halcyon day, we could at least aggressively extend SQL to make it less = awful. > On Feb 10, 2022, at 14:38 , Benedict Holland = wrote: >=20 > This is a strange post. Why is SQL bad and how do your reconcile that = with managing 99%+ of all data? It's so bad that we have systems that = plug into sql to query data outside of tables like Athena or Excel.=20 >=20 > Why are you not using pgadmin4? Yes. Psql as a command line isn't = great for humans. It's spectacular for computers though. So we have = pgadmin4, which I would take over any other database ui.=20 >=20 > Do you not want your views to change with underlying base tables = changing? Do a fully specified select. It's better programming anyway. = Do you want an api? That seems like a bad idea (i would never implement = it) but you also have a postgres socket, flask, and sqlalchemy or = psycopg2. It would take a few hours to write your own. Again, please = don't do that. You will almost surely lose user information like who = decided to delete your client data and your api would likely require = user privileges to get passed by token (sso would be a nightmare to = authenticate) or simply give root privileges to an api. Both are = honestly really bad.=20 >=20 > Now if postgres had the ability to do schema change tracking with = rollback... now that would be a victory. But there are sort of 3rd party = solutions that sort of work some of the time. It's a hard problem and = automated sql generation, particularly automated schema migrations, are = really hard to build in general and there are specific things that are = damn hard to not break.=20 >=20 > Thanks, > Ben >=20 >=20 > On Thu, Feb 10, 2022, 4:13 PM Bruce Momjian > wrote: > On Thu, Feb 10, 2022 at 06:25:45PM +0100, Peter J. Holzer wrote: > > On 2022-02-10 18:22:29 +0100, Peter J. Holzer wrote: > > > On 2022-02-09 21:14:39 -0800, Guyren Howe wrote: > > > > =E2=80=A2 SELECT * - b.a_id from a natural join b > > > > =E2=96=A1 let me describe a select list by removing fields = from a relation. In > > > > the example, I get all fields in the join of a and b = other than the > > > > shared key, which I only get once. > > >=20 > > > Natural join already does this. > > >=20 > > > My use case for such a feature are tables which contain one column = (or a > > > small number of columns) which you usually don't want to select: A = bytea > > > column or a very wide text column. In a program I don't mind (in = fact I > > > prefer) listing all the columns explicitely, but exploring a = database > > > interactively with psql typing lots of column names is tedious > > > (especially since autocomplete doesn't work here). > >=20 > > Forgot to add: I think that the syntax would have to be more = explicit. > > It's too easy to mix up > > SELECT * - b.a_id FROM ... > > and > > SELECT *, - b.a_id FROM ... > >=20 > > Maybe > > SELECT * EXCEPT b.a_id FROM ... >=20 > Yes, this was proposed on hackers a few months ago and a patch was > proposed: >=20 > = https://www.postgresql.org/message-id/flat/892708.1634233481%40sss.pgh.pa.= us#1f17923ad50a1442867162991c54ead9 = >=20 > The last post was from October of 2021 so you can email the author to > ask about its status. >=20 > --=20 > Bruce Momjian > = https://momjian.us > EDB https://enterprisedb.com = >=20 > If only the physical world exists, free will is an illusion. >=20 >=20 >=20 --Apple-Mail=_4708BB79-E1A8-4E8A-ADB3-3EE6440D4EEC Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 When = you dig into it, the powerful idea here is the relational algebra, and = its equivalence to a first-orderish logic.

I put up with SQL so I can use = relations, and I love Postgres because it has the least bad SQL (by a = mile!)

But SQL = is a terrible, no good, very bad language.

I don=E2=80=99t really understand why = folks who love the relational model aren=E2=80=99t perpetually up in = arms about SQL being their only option. Much better query languages are = known and well studied.

https://www.scattered-thoughts.net/writing/against-sql

I=E2=80=99d love = to see Postgres offer say Datalog. But until that Halcyon day, we could = at least aggressively extend SQL to make it less awful.

On Feb = 10, 2022, at 14:38 , Benedict Holland <benedict.m.holland@gmail.com> wrote:

This is a strange post. Why is = SQL bad and how do your reconcile that with managing 99%+ of all data? = It's so bad that we have systems that plug into sql to query data = outside of tables like Athena or Excel. 

Why are you = not using pgadmin4? Yes. Psql as a command line isn't great for humans. = It's spectacular for computers though. So we have pgadmin4, which I = would take over any other database ui. 

Do you not = want your views to change with underlying base tables changing? Do a = fully specified select. It's better programming anyway. Do you want an = api? That seems like a bad idea (i would never implement it) but you = also have a postgres socket, flask, and sqlalchemy or psycopg2. It would = take a few hours to write your own. Again, please don't do that. You = will almost surely lose user information like who decided to delete your = client data and your api would likely require user privileges to get = passed by token (sso would be a nightmare to authenticate) or simply = give root privileges to an api. Both are honestly really = bad. 

Now if postgres had the ability to do schema = change tracking with rollback... now that would be a victory. But there = are sort of 3rd party solutions that sort of work some of the time. It's = a hard problem and automated sql generation, particularly automated = schema migrations, are really hard to build in general and there are = specific things that are damn hard to not break. 

Thanks,
Ben


On Thu, Feb = 10, 2022, 4:13 PM Bruce Momjian <bruce@momjian.us> = wrote:
On Thu, Feb 10, 2022 at 06:25:45PM +0100, Peter = J. Holzer wrote:
> On 2022-02-10 18:22:29 +0100, Peter J. Holzer wrote:
> > On 2022-02-09 21:14:39 -0800, Guyren Howe wrote:
> > >   =E2=80=A2 SELECT * - b.a_id from a natural = join b
> > >       =E2=96=A1 let me describe a = select list by removing fields from a relation. In
> > >         the example, I get all = fields in the join of  a  and b other than the
> > >         shared key, which I only = get once.
> >
> > Natural join already does this.
> >
> > My use case for such a feature are tables which contain one = column (or a
> > small number of columns) which you usually don't want to = select: A bytea
> > column or a very wide text column. In a program I don't mind = (in fact I
> > prefer) listing all the columns explicitely, but exploring a = database
> > interactively with psql typing lots of column names is = tedious
> > (especially since autocomplete doesn't work here).
>
> Forgot to add: I think that the syntax would have to be more = explicit.
> It's too easy to mix up
>     SELECT * - b.a_id FROM ...
> and
>     SELECT *, - b.a_id FROM ...
>
> Maybe
>     SELECT * EXCEPT b.a_id FROM ...

Yes, this was proposed on hackers a few months ago and a patch was
proposed:

        https://www.postgresql.org/message-id/flat/892708.1634233481%40= sss.pgh.pa.us#1f17923ad50a1442867162991c54ead9

The last post was from October of 2021 so you can email the author to
ask about its status.

--
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                  =                     https://enterprisedb.com

  If only the physical world exists, free will is an illusion.




3D""= --Apple-Mail=_4708BB79-E1A8-4E8A-ADB3-3EE6440D4EEC--