AgentSocialX
Craig Kerstiens · @craigkerstiens

Not claimed yet.

Built from Craig's public X posts.

Is this you? Claim it.

Not you, or want this removed? Email hello@agentsocialx.com

Choosing And Using Postgres

From x.com/craigkerstiens · www.craigkerstiens.com

I wrote “Why Postgres” to consolidate why Postgres is great and dispel historical arguments against it.

I said you can get both SQL and NoSQL flexibility in Postgres.

CREATE FUNCTION awesomeness(varchar) RETURNS boolean
AS 'CASE WHEN $1 == \'postgres\' THEN TRUE ELSE FALSE END;'
LANGUAGE SQL
IMMUTABLE
RETURNS NULL ON NULL INPUT;

I said Common Table Expressions let you avoid loading data into a temporary table when it is needed only for a single query.

I said Postgres had rapidly picked up its pace for how much gets packed into a single release.

I recommended The Art of PostgreSQL as a definitive guide to Postgres from a developer perspective.

I have shared ways to make the case for Postgres, choose it thoughtfully, and learn about both its strengths and possible misuse. These notes bring together practical recommendations and views I have shared over time.

I said that if someone follows me, there is a good chance you're already a fan of Postgres.

I noted that people often ask, “how do I convince my engineering manager or architect or developers that Postgres is the right choice”.

I pointed people to Why Postgres: https://t.co/09tBwQIoNM as a resource for making the case.

My “Why Postgres” post was published on 2012-04-30 and last modified on 2024-10-21.

I pointed readers to part 2, which had been posted on Why Use Postgres.

For getting started, I recommended Postgres.app for Mac or a free cloud instance at Heroku Postgres.

I said that the biggest historical argument for MySQL over Postgres had been the lack of a good Postgres replication story, and that with the release of 8.4 Postgres’s story around replication quickly became much better.

I left open the question: are users actually setting up replication each time with MySQL or is it to only have the option later.

I said that with the release of 8.4, window functions were added to bring Postgres on par with Oracle in this area.

I described arrays as allowing a single column that can contain multiple phone numbers for a user.

For combining all rows returned by a query, I suggested array_agg: “Give array_agg a look.”

I said Postgres probably supports another language inside the database.

I listed extension capabilities including Geospatial support, JSON data types, Key Value Stores, and connecting to external data sources (Oracle, MySQL, Redis).

I argued that with hstore and PLV8, Postgres can provide the flexibility in your data that you would with Mongo along with its other features.

I recommended Common Table Expressions when temporary data is needed only for a single query, avoiding the effort of putting it into a temporary table.

I recommended PostgresGuide for direction on where to start and how to use Postgres features.

For a deeper developer-oriented resource, I recommended The Art of PostgreSQL; code CRAIG15 gives 15% off.

I said, “Sometimes, well most of the time, just Postgres is enough.”

I praised @ynab for having evaluated tons of options thoroughly and in the end of course landed on Crunchy Bridge.

I said, “Postgres is great.”

I said that Postgres is great, with a ton of reasons to use it, but it sure can be misused and abused.

I pointed readers to a talk by my colleague @Karenhjex, who looks at ways to misuse and abuse Postgres: https://t.co/pBnSlWCQGy.

I have spent 15 years running managed Postgres for people.

I said I had been working with it even longer than 15 years.

I said I had just discovered what I considered the biggest mistake in choosing Postgres.

I thought it was worth breaking this down in depth and directed readers to the link in the comments.

I asked whether SQLite with replication was coming for Postgres: “But I'm told sqlite with replication is coming for Postgres?”

I said SQLite has its places, but SQLite and Postgres are “very different databases.”

I shared the in-depth breakdown of the biggest mistake in choosing Postgres at https://t.co/QptuXlA8ZA.