r/programming • • 8d ago

PostgreSQL 19 Released!

https://www.postgresql.org/about/news/postgresql-19-released-3449/
838 Upvotes

33 comments sorted by

View all comments

32

u/X-lem 8d ago

Can we add a new column after another column yet?

12

u/leros 8d ago

I just want to reorder columns.

0

u/baseballlover723 8d ago

If you could reorder columns, then you could do this (and more), cause you could just add a column to the end and then immediately reorder it to where you want it.

14

u/halcyon_aporia 8d ago edited 8d ago

Why do people want this?

Edit: Huh, interesting. I literally never use a GUI with postgresql, so it never even occurred to me. Fair enough.

19

u/baseballlover723 8d ago

makes it easier to read when related columns are next to each other. Or are in some kind of grouping.

An easy scenario to image is you start with 1 metric column, say column 2 of 10. And then some years later you come up with another metric, and you want to see how it compares to your original metric. If it's in column 3, you can shift your eyes back and forth between them quite easily. If you have to cross 8 unrelated columns, then it's much less efficient for you to process the data.

And for the sake of argument, lets say that those 8 columns contain secondary information and the query takes some time to run, so simply omitting the other information also creates a big hassle.

6

u/badmonkey0001 8d ago

makes it easier to read when related columns are next to each other. Or are in some kind of grouping.

It also makes CREATE statements cleaner to read if anyone needs a non-GUI reason.

7

u/halcyon_aporia 8d ago

You could always just run a select with the columns you want in the order you want, can't you? The result set will be in the order you select them.

11

u/baseballlover723 8d ago

I mean you could. But doing something every single time you want to use a * query (which is quite common for me) is a huge annoyance.

Just like how I could just type out my underlying view query every single time instead of just querying a view I wrote once.

Convenience is worth something imo. And needing to type out all of my columns for most of my queries is very inconvenient.

3

u/josh_ml_1127 8d ago

Convenience wins; listing all columns for most queries is a pain.

2

u/SenoraRaton 8d ago

I mean you could. But doing something every single time you want to use a * query (which is quite common for me) is a huge annoyance.

Store it as a view and access the view directly?

5

u/baseballlover723 8d ago

So then I have a table I never use, and a view that is virtually identical to the table I never use. And they both have to have names, which ideally describe them, but can't be the same.

I mean it works, but it doesn't feel like a good solution to me cause 2 things that apparently do the same thing is sure to cause confusion.

2

u/OSS-Corpo-Shit 2d ago

When my users are using my software and they tell me about these things they do to work around things my software does, I take that as an indication that my software needs to change.

7

u/baseballlover723 8d ago

Edit: Huh, interesting. I literally never use a GUI with postgresql, so it never even occurred to me. Fair enough.

It's even more relevant in the CLI, where you don't get things like expandable cells or could potentially have a post query feature to rearrange things (though idk if any sql gui actually lets you do that).

Wrapping is a huge issue too. Imagine you have a table that stores reddit comments. There's a bunch of relevant fields, the id36, the username of who posted it, the body, when it was made, etc. If one of your middle fields has a very long width or has new lines in it, then everything after it can't be aligned and when one column is taking up 2-20 rows, it's really hard to read, because it's not very clear where one row starts and the next ends, or if it's in the middle of another column.

At least with a gui, you don't need to have all of the information being shown on the screen all the time, and you can simply show an excerpt of a really long cell, and have it expand on click etc.

4

u/leros 8d ago

When you query tables in a GUI tool the columns are ordered in the natural order of the table. Any new columns are at the end with Postgres. It's really annoying. Other databases let you modify the order.

2

u/davvblack 8d ago

guis use column order, and the dump

2

u/leros 7d ago

GUI tools are pretty common when you're doing ad-hoc data analysis

3

u/X-lem 8d ago

created/updated/deleted at should always (imo) be at the end. If I see those columns I assume there's no more. I've found I miss columns when they're "hidden" after that.

Also column grouping makes things easier to read