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 1k0tLg-0005rx-Mn for pgsql-admin@arkaria.postgresql.org; Wed, 29 Jul 2020 21:10:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k0tLd-0000dC-PD for pgsql-admin@arkaria.postgresql.org; Wed, 29 Jul 2020 21:10:49 +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 1k0tLd-0000d5-GF for pgsql-admin@lists.postgresql.org; Wed, 29 Jul 2020 21:10:49 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k0tLW-0007KQ-W4 for pgsql-admin@postgresql.org; Wed, 29 Jul 2020 21:10:48 +0000 Received: by mail-oi1-x22a.google.com with SMTP id k4so21996213oik.2 for ; Wed, 29 Jul 2020 14:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gautherot.net; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Onj1TKu6SQ4JinxT/t7s4JCYvJ+1CwSmUP6v3VJKhTA=; b=YhV7F09tgGEouGUwG3rRBqFzm9Sja2Sy3Kg7rh/hIwEqs/O+VRZ5rZLrSh64tMOyHZ FaBJgCQBrkLV9w0iOO6KGRF/HHITtdTGfFrzHedaqoDMoAXMd0Nx71/hVzIDsIKI+2RS wwds0qubAl0mCxzWXN5waVVmpKgUDKDDHWnOJ6FB9qEa2nh0cwcunu082+cm0AzUmDfB 0pFX+RzScNRXCyxQ0VCYXmTVmfOS7fsrLNWqHQTRwKH2eaBF95+GLLvIxmAhQ/DhCPY3 D9FMC4mrffkAn3V+nVqzu7qvxZuIx5jE7xXJQH6aMcnxfFWBTy+E4cJmoH+hdJxN8/v2 cScw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Onj1TKu6SQ4JinxT/t7s4JCYvJ+1CwSmUP6v3VJKhTA=; b=P6wtkMyfLKNUDYw3OASxvFUWXO44tzJjjC5Gd2xQk04Sbiiz6QdD+jIDZ/ZRfsYNhz L3MOltlJkmE25LsdbsWl1fWAv6XnnRMzckAqo8jYM2FEqZCULhQinrKOuIjYrWJmEeLz 9p7t5eqTX5eFbOaptF1mdCdrM4EWp4S/utjkRrbPIj7jXeHC8d8uyHbqKdAPRV1CYpKb U9i7bc7GyZKPFU6ZS+UQgxtmBWoq22UdxK3zCl6GnoiYmv/CA85kOX4FSS5hbtzDR4NJ iD21Aj9kK4RN0dk2Acp055B6GbVkg2u8snjcklHfGKipMkambSiIcwQUxpopM82v3+mf YO8g== X-Gm-Message-State: AOAM530eqk3u+rZj7z/f17T+sden5wfw0ZCm1fFoQuSShKuwk1C8a/Os 8XljIl8LB+bc/iazkXn3Ovl8XEqYWOmYgO8GmExsVg== X-Google-Smtp-Source: ABdhPJzRnE88AvoVrd2cgFS2XXeQwQwfqBwfylkDo/VEMMw90WchQjDIsTVdkMPN7kxp24DBnwMpDr4uv/ERGNS0kEM= X-Received: by 2002:a05:6808:7de:: with SMTP id f30mr9274741oij.15.1596057041986; Wed, 29 Jul 2020 14:10:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Olivier Gautherot Date: Wed, 29 Jul 2020 23:10:29 +0200 Message-ID: Subject: Re: Re-order columns? To: "David G. Johnston" Cc: Wells Oliver , pgsql-admin Content-Type: multipart/alternative; boundary="000000000000077dbb05ab9afd0f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000077dbb05ab9afd0f Content-Type: text/plain; charset="UTF-8" Hi, On Wed, Jul 29, 2020 at 10:45 PM David G. Johnston < david.g.johnston@gmail.com> wrote: > On Wednesday, July 29, 2020, Wells Oliver wrote: > >> I know this kind of dumb, but is there a way to re-order columns? You >> know, you have your awesome table all defined, your favorite modified_at >> column at the end where you like it, then some guy comes along and is like >> "oh let's add X Y and Z" and your OCD really really really wants the >> modified_at col at the end, and blowing away/re-populating the table takes >> way too long >> > > There is not. Every so often this gets looked at but has yet to result in > a commit. > It is an issue that pops up regularly and there are technical issues behind. It has been fixed in other engines but not yet here. If it is critical for your application, I could suggest 2 ways: 1) run a SELECT INTO taking care of the proper column order everytime you ALTER the table (it may or may not be doable depending on your specific case) 2) place a view in front of the table with the expected order The latter will surely reduce the maintenance, overhead, downtime... Now if the order is really critical, you should probably specify the columns list when you access the table (knowing it can be a pain if there are many). Note that if it gets solved, it will most probably be done in the catalog and not the table itself. Hope it helps Olivier --000000000000077dbb05ab9afd0f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Wed, Jul 29, 2020 at 10:45 PM Dav= id G. Johnston <david.g.jo= hnston@gmail.com> wrote:
On Wednesday, July 29, 2020, Wells Oliver <wells.oliver@gmail.com&g= t; wrote:
I know this kind of dumb, but is there a way to re-order columns? You = know, you have your awesome table all defined, your favorite modified_at co= lumn at the end where you like it, then some guy comes along and is like &q= uot;oh let's add X Y and Z" and your OCD really really really want= s the modified_at col at the end, and blowing away/re-populating the table = takes way too long
<= /div>

There is not.=C2=A0 Every= so often this gets looked at but has yet to result in a commit.

It is an issue that pops up regularly and there= are technical issues behind. It has been fixed in other engines but not ye= t here.

If it is critical for your application, I = could suggest 2 ways:

1) run a SELECT INTO taking = care of the proper column order everytime you ALTER the table (it may or ma= y not be doable depending on your specific case)

2= ) place a view in front of the table with the expected order

=
The latter will surely reduce the maintenance, overhead, downtim= e... Now if the order is really critical, you should probably specify the c= olumns list when you access the=C2=A0table=C2=A0 (knowing it can be a pain = if there are many). Note that if it gets solved, it will most probably be d= one in the catalog and not the table itself.

Hope = it helps
Olivier
--000000000000077dbb05ab9afd0f--