Menu

1 / 10

Database Indexing – Part 4: Covering vs. Composite Indexes in PostgreSQL – Which One Should You Use?

DEV Community: postgres·Anusha Renangi·4 days ago
#4iSlkBDD
#devtopostgresql#devto#dev#index#composite
Reading 0:00
15s threshold

In my previous articles, we explored covering indexes and composite indexes separately.

Both indexes can improve query performance, but how do they differ in terms of storage, INSERT, UPDATE, and SELECT performance?

To understand this, I tested both index types in PostgreSQL using two different datasets: one with unique values in the first indexed column and another with duplicate values.

In this article, we'll compare the results of these experiments and understand when to use covering and composite indexes in real-world applications.

Experiment 1: Covering vs. Composite Indexes with Unique Key Values

To compare covering and composite indexes, we'll perform a few experiments in PostgreSQL using 10 million records .

We'll use two separate tables with identical structures and data, so we can test both index types independently.

1.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.