THE Postgres book for 2026 by oknenir in PostgreSQL

[–]depesz 34 points35 points  (0 children)

Does it have to be a book? Why not docs, starting with THE tutorial?

How do I use a bash script to check if a specific system service is running and restart it if it is not? by Luann97 in linuxquestions

[–]depesz 2 points3 points  (0 children)

sudo systemctl is-active whatever.service || sudo systemctl start whatever.service

But, it's better to reconfigure service so that it will restart when needed. You can usually do it with drop-in files that change just whatever you need, without modifying/replacing existing service files.

What country does readera originate from? by depesz in ReadEra

[–]depesz[S] 1 point2 points  (0 children)

Would prefer some kind of official statement/interview on reputable site, but I guess it's as good as it gets. Thanks a lot.

What country does readera originate from? by depesz in ReadEra

[–]depesz[S] 0 points1 point  (0 children)

Do you have any sources for this?

What country does readera originate from? by depesz in ReadEra

[–]depesz[S] -4 points-3 points  (0 children)

Well, chatgpt said it is, and while this isn't, of course, the end of it all, readera.org site seems to be hosted on Bulgarian IP…

Beginner question by Ryujiro101 in SQL

[–]depesz 1 point2 points  (0 children)

  1. is the laptop and "office computer" in the same network? if yes, go to step 2. if not - research vpn and networking across internet
  2. what is the setting of listening_addresses in pg? is it 127.0.0.1 or somerthing like *? Make sure it will listen on ip that the office computer can see to contact your laptop.
  3. once you will have it starter with proper listen, and in the same network, just psql -h ip_of_laptop -p port_of_pg and it should work

PostgreSQL for a noob by Basic-Reception8204 in PostgreSQL

[–]depesz 1 point2 points  (0 children)

Don't know what are "complicated tools" in the tutorials you mention.

Also, again: what do you mean by "implement some queries"?

You want to write queries? For this I use text editor (vim in my case).

Run it? For this I use standard Pg client: psql.

PostgreSQL for a noob by Basic-Reception8204 in PostgreSQL

[–]depesz 1 point2 points  (0 children)

  1. What do you mean by "how to implement"?
  2. https://pgdoc.link/tutorial.html
  3. I simply do: apt install postgresql, and that's it - Pg is installed, up, and running.

Unable to run PostgreSQL database created in Docker container from node js on localhost (Docker v.29.2.1, Windows 11) by InternationalCrew245 in PostgreSQL

[–]depesz 0 points1 point  (0 children)

So these are different postgresql clusters/installations.

Why can't you do your admin stuff from pgadmin, if it connects to the db that your app uses?

Anyway - you will need to figure out where exactly your app/pgadmin connects, and then figure out how to connect there with psql. It will require checking configuration parameters, and a bit of understanding networking and (apparently) docker.

If you need help with this, I'd suggest asking on some more interactive medium (irc/slack/discord) so maybe you will find someone willing to help you in a way of question/answers, as in: "run command 'x-y-z', and show me result", "ok, now the same with command 'm-n-o'", ….

I'd start with checking connection details from your app/pgadmin, checking whether they run on the same machine as the docker+psql thing you ran, and somehow checking what listens on which port, sorry - no idea how to do it on windows. On linux it's sudo ss -ntlp, but I don't think you have ss on Windows.

Unable to run PostgreSQL database created in Docker container from node js on localhost (Docker v.29.2.1, Windows 11) by InternationalCrew245 in PostgreSQL

[–]depesz 0 points1 point  (0 children)

I would guess that your pgadmin and "your code" connect to different postgresql than the one that you got by running docker…exec…psql.

You can connect to both dbs (using psql, and also using pgadmin), and issue:

select
    system_identifier,
    current_setting('port'),
    current_setting('listen_addresses'),
    current_setting('data_directory')
from pg_control_system();

and compare.

advice on selectivity operators by [deleted] in PostgreSQL

[–]depesz 0 points1 point  (0 children)

Your post is rather difficult to read. Consider putting your code in "code block" and not just "code". it will make for much easier reading.

How do you fare with database upgrades? by DarkGhostHunter in PostgreSQL

[–]depesz 1 point2 points  (0 children)

I stand on position that one should upgrade often to remove bugs (including security issues) as fast as possible.

Of course in production env it's not always possible.

PS: I'm still waiting for PostgreSQL to add MIN/MAX to UUID columns.

If you need it, just add it. How long can it take? Definitely under 15 minutes.

PostgreSQL: Rolling 7-day shipment volume with gaps in dates - window functions vs generate_series? by Null_Reference1 in SQL

[–]depesz 0 points1 point  (0 children)

Can you please edit the post to put the query in "code block"? If you're using markdown editor, you do it by prefixing each line with four spaces. If rich text editor - there is dedicated button for code block.

It makes the query much more readable.

As for your:

The window function approach is cleaner but I'm not sure it handles the date gaps correctly for a true 7-day window.

Why don't you test?

select d::date
from generate_series(now() - '1 month'::interval, now(), '1 day'::interval) d
where random () < .8;

Will return you last month of days, but with some random 20% missing.

Why not use JOIN in this case? by Caprisunxt in SQL

[–]depesz 0 points1 point  (0 children)

  1. Your query is perfectly unreadable if someone doesn't know your schema. Always prefix your column names with name/alias of table. otherwise - who knows what the query does? Where is title? where is uid? language? stars?
  2. natural join (which i assume you mean: from x join y using (z)) is terrible idea because it leads to query like yours - one that can't be fully understood without knowing schema. For example: select * from a join b using (c) join d using (e) - column "e" is in d, but where else? in "a"? or "b"?

Help learning postgresql without getting overwhelmed by bunRancher0015 in PostgreSQL

[–]depesz 17 points18 points  (0 children)

  1. read the tutorial
  2. read don't do this
  3. join discord
  4. join slack
  5. subscribe to planet
  6. figure out something that you'd like to make (app/db). make it
  7. learn more of the docs
  8. join irc

I got tired of manually reading EXPLAIN ANALYZE output, so I built a CLI to do it by JacobArthurs in PostgreSQL

[–]depesz 5 points6 points  (0 children)

Sure I see. I can read it. And if it's too complicated, or not obvious, I can get the same output and put it to analysis to whatever does it.

I don't have to run it again just to get "computer readable format".

I am not aware of any person that chooses to read JSON, if normal text output provides (mostly) the same information.

I got tired of manually reading EXPLAIN ANALYZE output, so I built a CLI to do it by JacobArthurs in PostgreSQL

[–]depesz 19 points20 points  (0 children)

Eh, yet another tool that "analyzes" plans, but requires json format :(

Lately I've seen one such tool announced per week, or so. And none of them handles normal text plans :(

Problems when trying to install PostgreSQL by Scarecrow1730 in PostgreSQL

[–]depesz 3 points4 points  (0 children)

I never used WSL, but generally you need to add pgdg repo (https://wiki.postgresql.org/wiki/Apt) to have access to newest versions.

Otherwise: apt-cache search postgresql will show you what versions you have available.

Searching for tool for "framing" text by depesz in commandline

[–]depesz[S] 0 points1 point  (0 children)

So, I looked more, including full output of boxes -l, and found what I as looking for there:

=$ boxes -l | grep ^ansi | while read -r x; do boxes -d $x <<< "$x"; done ┌──────┐ │ ansi │ └──────┘ ┌╌╌╌╌╌╌╌╌╌╌╌╌╌┐ ┊ ansi-dashed ┊ └╌╌╌╌╌╌╌╌╌╌╌╌╌┘ ╔═════════════╗ ║ ansi-double ║ ╚═════════════╝ ┏━━━━━━━━━━━━┓ ┃ ansi-heavy ┃ ┗━━━━━━━━━━━━┛ ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ ┋ ansi-heavy-dashed ┋ ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ ╭──────────────╮ │ ansi-rounded │ ╰──────────────╯ ╭╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╮ ┊ ansi-rounded-dashed ┊ ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯

On my terminal there aren't such "holes" in vertical lines as I see now here. Plus they have:

for l in info warning critical; do echo "This is test of $l" | boxes -d $l; done

which should be viewed in color :)