1. 25

Hey Lobsters community! šŸ‘‹ I’m diving into the world of PostgreSQL and curious about the tools fellow developers use to interact with this fantastic database.

1- What are your go-to tools or software for managing, querying, or interacting with PostgreSQL databases?

2- Any particular GUI clients, command-line tools, or libraries you find indispensable for your PostgreSQL workflows?

3- Are there any lesser-known or niche tools you’ve discovered that have made your PostgreSQL experience smoother or more efficient?

Looking forward to learning from your experiences and recommendations! Thanks in advance for sharing your insights! 🐘✨

    1. 12
      • psql with pspg for viewing results
      • pdot (my tool) for exploring structure
      • pgtap for testing
      1. 2

        Is there a pspg tour or something to quickly learn some of its most valuable features?

        1. 3

          I don’t know of any but F9 brings up a menu and the readme / man page do a decent job of summarizing toward the top. The most valuable feature is 2D scrolling and that’s right in front of you anyway.

          1. 2

            Thank you!

        2. 2

          Wow, I have great hopes that pspg will eliminate the need of \x (or \G in MySQL). That’s a muscle memory thing I’d be glad to rid.

          1. 1

            thanks for sharing this list. Nice work with pdot! I’ll give it a try..

          2. 12

            My go-to CLI client is pgcli: https://www.pgcli.com/. For examining the output of logical replication slots using pgoutput encoding, I’ve built a CLI tool myself: https://github.com/gunnarmorling/pgoutput-cli.

              1. 2

                I use DataGrip primarily for Redshift. It’s largely good. It can get hung up on a large database when you write out select [common column name] because auto complete starts scanning through databases. Helps to write out the from clause before selecting out columns sometimes. Still, I would recommend it.

                1. 2

                  How much different is this to the Database plugin/tool in the other IntelliJ-based IDEs?

                  I moved to IDEA Ultimate + multiple language plugins several years ago, and it’s always seemed a little bit odd that the languages are available both as a plugin and a ā€œfull IDEā€.

                  1. 4

                    I believe that, as with the various languages, all the functionality is there in IDEA Ultimate’s database plugin. The features are a little easier to discover in the individual IDEs, and the UX is a little bit better IMO. But I don’t think there’s a thing you can’t do with the IDEA Ultimate + plugin but could do with DataGrip.

                    They are candid about this here:

                    https://www.jetbrains.com/products/compare/?product=idea&product=datagrip

                  2. 1

                    I wish I could afford this, it looks amazing. Makes sense to spend that much if I was doing DB work daily or if company was paying for it but their pricing is really steep for what I’m doing! Are you claiming it as a work expense?

                    1. 3

                      Not OP, but I have paid for the JetBrains bundle myself for a number of years. It’s more than paid for itself in terms of my ability to get up to speed on different tools and technologies.

                      1. 2

                        Seconded, the JetBrains bundle is definitely worth the money and they have a student discount available if you have any .edu email

                  3. 9

                    I use DBeaver (Community Edition) every day to interact with multiple PgSQL DBs: running queries, inspecting schemas, saving queries. The transactional mode is handy when I have to operate on a production DB. It is such a handy tool. (Not specific to PgSQL, you can use other supported databases as well)

                    1. 5

                      I’ll second DBeaver, I use it daily with both Postgres and Greenplum. My other go-tos are pgsql on the cli and psycopg in python.

                      1. 5

                        Annoying DBeaver quirk: it automatically converts dates to the local time zone. If you are working on a distributed team this can lead to people freaking out. I recommend turning that setting off.

                        1. 3

                          From a UI perspective this is one of the worst things I have ever had to see. It’s incredibly off-putting to use.

                          1. 2

                            I just downloaded it to check it out, and I honestly cannot see what’s wrong with it. It’s your bog-standard IDE-type application. I’m using it on Gnome and it looks fine.

                            1. 2

                              I counted some five levels of tab bars going on the same screen.

                          2. 1

                            Looks promising! do you know how it compares to tableplus?

                            1. 2

                              I don’t know how it compares, but you can simply download community edition and try it for yourself. I highly recommend, it’s great software.

                          3. 8

                            95% of the time: psql and tmux with a personalized .psqlrc file and EDITOR set to either vim or emacs.

                            rest of the time: datagrip, QGIS/ogr2ogr, programmatically through libpq or ruby pg, or python psycopg or whatever pg library for a given language i’m using.

                            1. 8

                              I mostly rely on psql for querying and such. It really pays off learning its ins and outs! For performance analyses there’s three nice tools I’ve used:

                              1. 7

                                99% of the time I’ve been raw-dogging psql. Sometimes I hop unto pgcli

                                1. 7

                                  I don’t use it for pg, but TablePlus is a pretty nice multi-db client.

                                  1. 2

                                    This has been my go-to for years after switching from navicat

                                    I’ve tried many others but tableplus hits the sweet spot for me.

                                    1. 2

                                      Concur here, TablePlus has been a sanity saver for me

                                    2. 7

                                      I use pgcli as a CLI improvement for psql. It has a cousin litecli that will give you the same experience for SQLite, which is nice.

                                      When using Postgres via an ORM (Django), I’m often in IPython. Browsing the results of queries from IPython is not that nice, but I found I can integrate visidata quite nicely into IPython with some glue code I wrote.

                                      You can also use visidata with postgresql directly.

                                      1. 6

                                        Great question!

                                        1- What are your go-to tools or software for managing, querying, or interacting with PostgreSQL databases?

                                        pgcli + pspg are indispensable to me

                                        2- Any particular GUI clients, command-line tools, or libraries you find indispensable for your PostgreSQL workflows?

                                        I’ve given up on GUI clients, but sometimes good old pgAdmin can still be handy.

                                        A good way to find interesting and valuable postgres extensions is to check out the ones selected by Supabase (which is a great project in intself): https://supabase.com/docs/guides/database/extensions and to follow this wonderful, never-ending issue discussion on GitHub: Vote for Postgres extensions

                                        Migrations is a big and somewhat underappreciated topic (most people use an ORM or something similar integrated into their app platform to manage migrations). The most comprehensive choice is probably Sqitch but it’s also worth looking at ā€œdeclarative migrationsā€ tools where you just write the SQL you want and the tool creates the migration you need. Two interesting choices are Atlas and Tusker. (I can’t vouch for either though.)

                                        3- Are there any lesser-known or niche tools you’ve discovered that have made your PostgreSQL experience smoother or more efficient?

                                        I am a big fan of tools that infer an API (REST or GraphQL) directly from the database schema. I have the most experience with PostGraphile. PostgREST is the grandmommy of them all and still going strong. Hasura is by all appearances also great, but I haven’t used it.

                                        1. 5

                                          I bought a TablePlus license. It’s not perfect but does what I need: visualize my tables, inline edits in the table (with manual commit), and raw queries. The UI is sometimes a bit confusing but all in all it’s a good client.

                                          1. 2

                                            tableplus is great IMO if your company will pay for the license!

                                            1. 3

                                              In my case I bought it myself because it’s pretty interesting: it’s a lifetime license with 1 year worth of updates. So after 1 year, you Ā« own Ā» the current version, and you can renew your license at a discount.

                                              I initially bought it for a year, and didn’t renew it for a while because I didn’t really care for the next updates. I renewed recently because of some updates I wanted related to Redis support

                                          2. 4

                                            I use Postico for quick queries and searches. It’s nice enough; there’s a persistent SQL ā€œscratchpadā€ that I use a lot. I also find it more convenient than the CLI for checking table definitions. (I’m using v1, which is slightly cheaper.)

                                            1. 4

                                              Technically, it is not a tool for interacting with PostgreSQL but for monitoring it; in any case, it has saved my life a couple of times during production releases. Right now, what happens in the environment is entirely transparent to me, and it’s crazy how much happens without you even noticing.

                                              Inspired as well by the design of htop (or top): https://github.com/dalibo/pg_activity

                                              Edit: After reading every comment, I realized nobody mentioned the best open-source IDE for SQL out there: https://dbeaver.io/

                                              1. 4

                                                I like datagrip, but really only because I have a standing subscription to JetBrains’ all products pack. (Back before they moved to subscriptions, my company was reimbursing me for PyCharm and Clion. When they moved to subscriptions, it was cheaper to get the full line than to buy those two. I’ve since moved on, but have continued to pick up the renewals myself because I get quite a lot of usage out of more than two of their tools.)

                                                As you’re just diving in, though, I’d recommend sticking to the built in psql command line tool for a while. And I’d strongly recommend picking up and working through the book A Curious Moon. It was a fun, engaging way to learn a lot about postgres in just a few days. I haven’t enjoyed any other tech book this much, and postgres might be the topic about which I’d have least expected to enjoy a book.

                                                1. 1

                                                  Looks like the kind of learning I really need. Thanks for taking the time to share

                                                2. 3

                                                  I have a funny one for you. org-mode in emacs! Whyever would I do that you ask?

                                                  Because I prototype queries and schema changes in source code blocks, and the results are saved in my notes. I can press C-c C-c in the query and that immediately updates the RESULTS block below the query.

                                                  #+begin_src sql :engine postgresql
                                                    \d import.master_plan
                                                  #+end_src
                                                  
                                                  #+RESULTS:
                                                  | Table "import.master_plan" |      |           |          |         |
                                                  |----------------------------+------+-----------+----------+---------|
                                                  | Column                     | Type | Collation | Nullable | Default |
                                                  |   start_time_utc           | text |           |          |         |
                                                  |   duration                 | text |           |          |         |
                                                  |   date                     | text |           |          |         |
                                                  |   team                     | text |           |          |         |
                                                  |   spass_type               | text |           |          |         |
                                                  |   target                   | text |           |          |         |
                                                  |   request_name             | text |           |          |         |
                                                  | library_definition         | text |           |          |         |
                                                  |   title                    | text |           |          |         |
                                                  |   description              | text |           |          |         |
                                                  

                                                  I write my org-mode notes such that I start with a question like: Am I able to use the ltree operators to update large jsonb fields? I incrementally build my own answers by starting with snippets that teach me the operators, and then accomplish the task, and I can go back and refresh my understanding from my notes.

                                                  This sort of literate programming has been unexpectedly useful when a coworker accidentally broke our schema and no one else noticed!

                                                  Bonus points if you recognize the schema above from a postgresql book!

                                                  1. 3

                                                    I always liked psql and commands like \dt,explain analyze, etc. dbcli is also a fun tool with good autocompletion.

                                                    1. 3

                                                      psql I guess. It kinda sucks for editing long queries, but you can run it on the server and don’t have to tunnel anything. https://explain.depesz.com/ is of course great for visualizing explains.

                                                      1. 7

                                                        For long queries there’s always \e

                                                          1. 1

                                                            The day I Led this one was pretty huge for me

                                                        1. 1

                                                          I literally need to have one window open with https://www.postgresql.org/docs/current/app-psql.html to do anything right now.

                                                          1. 2

                                                            I just use the man page. They are also handly for syntax (e.g. man ALTER_TABLE).

                                                            1. 3

                                                              Try \help ALTER TAB<tab><tab> in psql. It’s usually enough of a reminder for me to finish what I need to do.

                                                          1. 2
                                                            • psql for quick things
                                                            • PgAdmin when I want a GUI, such as graph output from EXPLAIN ANALYZE. PgAdmin is hugely featureful. The UI is a bit weird but it’s fine.
                                                            • Python wrappers around psql/pg_dump/pg_restore for automating database cloning, minimizing, sanitizing, etc. for development purposes
                                                            1. 2

                                                              pgadmin is pretty nice.

                                                              I also have the postgres docs in Zeal and look at them all the time when trying to recall certain syntax/behavior. Docs are alright.

                                                              If you’re already kinda versed in SQL, then this site is a full explanation of loads of Postgres stuff implementation. Should help to understand what is a good or bad idea to do in pg. Goes deep in how data is stored on disk.

                                                              1. 3

                                                                pgadmin is pretty nice.

                                                                You sure about that? PgAdmin is easily one of the worst UIs I’ve ever had to use. It makes everything way harder than it needs to be. The public tables are buried in like 4 or 5 nesting levels, and last time I used it I couldn’t for the life of me figure out how to run a raw query. Everything complicated and useless is right in your face, and everything simple and useful is… god knows where.

                                                                I don’t know if you have used other tools but I really suggest you try to do so, for your own good.

                                                                1. 2

                                                                  Shrug, I guess I’m used to it. I also have used other stuff just fine, but they were often embedded in other tools (like the Jetbrains querying tool embedded into all of their IDEs)

                                                              2. 1

                                                                M-x sql-postgres in Emacs, or psql if that’s not available for some reason.

                                                                I don’t have direct SQL access to our production RDS DBs, but we have an PgAnalyse instance that I can use to answer some questions. I like it, though I haven’t used any of the other tools mentioned here so don’t know how it compares.