60% of the tables I have recently designed, do not

Arpit Bhayani

Arpit Bhayani

Dec 17, 2024 • 1 min read


60% of the tables I have recently designed, do not have the standard auto-increment ID column.

Although counter-intuitive, doing this has helped me gain a significant performance boost because of smaller table sizes (data plus index); particularly for the cases where we paginate more than we do pointed reads and updates.

This required me to not use ORM and I happily took that tradeoff to get better query control and performance.

This design choice is purely made after I have understood how a relational database (MySQL in my case) stores the data and evaluates the query; definitely not a one-size-fits-all design decision.

So, whenever you are designing a schema, always optimize for the most frequent queries and even if it requires going for a composite primary key, it may be worth it.

also, knowing a bit about database internals always helps.

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses