# Exploring a new Postgres database

DevFeed: [Exploring a new Postgres database](<https://devfeed.tech/articles/exploring-a-new-postgres-database-41225.md>)

Original publisher: [Read original article](<https://www.craigkerstiens.com/2020/11/14/Exploring-a-new-Postgres-database/>)

Author: Map

Published: 2020-11-14T19:30:56Z

Content type: tutorial

Language: en

Sources: [Craig Kerstiens](<https://devfeed.tech/sources/craig-kerstiens.md>)

Topics: [Database](<https://devfeed.tech/topics/database.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [file](<https://devfeed.tech/topics/file.md>), [Sequences](<https://devfeed.tech/topics/sequences.md>), [Heroku](<https://devfeed.tech/topics/heroku.md>)

Tags: [cli](<https://devfeed.tech/tags/cli.md>), [cloud](<https://devfeed.tech/tags/cloud.md>), [databases](<https://devfeed.tech/tags/databases.md>), [file](<https://devfeed.tech/tags/file.md>), [heroku](<https://devfeed.tech/tags/heroku.md>), [postgres](<https://devfeed.tech/tags/postgres.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [psql](<https://devfeed.tech/tags/psql.md>), [sequences](<https://devfeed.tech/tags/sequences.md>)

## AI overview

A practical guide to exploring an unfamiliar Postgres database using the psql command-line client. It covers configuring psql defaults, inspecting database objects and tables, examining data, formatting output, and working with JSONB.

## Source excerpt

At past jobs I'd estimate we had 100 different production apps that in some way were powering key production systems. Sure some were backend/internal apps while others key production apps such as the dashboard itself. At other companies we had a smaller handful of Heroku apps that powered our cloud service, about 5-10 in total. Even just working with those internal apps it's a number of things to keep context on. But when it comes to interacting with something you don't know getting a lay of the land quickly is key. In helping a customer optimize and tune, or even just understand what is going on in their app an understanding of the data model is key. As I just started a few months back at Crunchy Data I found myself digging into a lot of new systems and quickly trying to ramp up and get a feel for them. Over the past 10 years I've pretty well codified my steps to getting a feel for a new database. While I'm not a DBA and a small portion of my job is spent inside a database being able to quickly navigate one saves me hours each month and days out of the year. I'm sure my process isn't perfect, but hopefully it helps other when navigating a new Postgres database for the first time. First the tooling For any new database my go to tool is psql. The built-in Postgres CLI is going to be the quickest thing for me to navigate around. If you use a CLI for anything else then this should be your preference here as well. I'm also going to have a psqlrc file setup that has some good defaults. My go to defaults in my psqlrc are: -- Automatically format output based on result length and screen \x auto -- Prettier nulls \pset null '#' -- Save history based on database name \set HISTFILE ~/.psql_history- :DBNAME -- Turn on automatic query timing \timing Getting a feel for the tables The first thing I'm going to do is just table a look at which objects exist within the database with \d. This will spit out a mix of tables, views, sequences all within your database. A cleaner version