Database Primary vs Secondary Indexes Simplified

Just a guy who loves to write code and watch anime.
Search for a command to run...

Just a guy who loves to write code and watch anime.
No comments yet. Be the first to comment.
Qualities that make outstanding builders.

Bipedal vs quadrupedal: how many legs This is about the number of legs the creature walks on. Bipedal. Two legs. Humans, ostriches, T-rex, kangaroos, most fantasy humanoids. Quadrupedal. Four legs. Do

Intro You hear "lerp" and "smoothstep" everywhere in game dev. They sound like math jargon. They're not. Both are small tools that do the same job: smoothly move from one value to another. The problem

What is Kinematics Kinematics is the math field. It's the study of how things move without worrying about forces (which would be dynamics). FK and IK are the two branches: forward kinematics and inver

Intro Textures are usually the biggest cost in a 3D scene. Memory, bandwidth, and load time all get eaten by them. Resizing them is the obvious lever. There's more. This post is about the less obvious

Imagine a primary index as a book's table of contents. Like how the table of contents shows the page number for each chapter, a primary index keeps the location of data records in a database. Each chapter (or data record) has a unique identifier, making it easy to find the exact chapter you need.
Unique Key: Each record has a unique identifier.
Ordered: Organized in a specific order (like alphabetical or numerical).
Efficient Access: Enables fast and direct retrieval of records.
Imagine doing a keyword search in a library catalog. You're not searching by the unique book ID (the primary index), but by topics or authors. This is like a secondary index, where you can search for records using attributes other than the primary key.
Non-Unique Attributes: Can reference attributes that are not necessarily unique.
Flexibility: Offers more ways to search for data than just the primary key.
Potential Trade-off in Speed: Can be slower than primary indexes, as it might involve an extra step to retrieve the actual record.
Primary Index: Like a book's table of contents, it's direct and efficient, using unique identifiers.
Secondary Index: Similar to a keyword search in a library catalog, it provides flexibility but might be slower.