4min chapter

Postgres FM cover image

Partitioning

Postgres FM

CHAPTER

How to Pick a Partition Key in Postgres

All primary key and all unique keys unique indexes must include partitioning key. If you have surrogate key like id in some integer or uid u l id anything version 5 6 i don't know anything nowYou can see that you're huge table to be partitioned by range using timestamp for example created at right now You need to redefine your primary key to have both id column and created at column. Foreign keys which reference to this primary key they also need to be rebuilt when you redefine primary key it's also not an easy jobyou need to think about if you need to do it for zero downtime, he says.

00:00

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode