Indexes: Quickstart Using PostgreSQL (15 sec read)

작성자

카테고리:

← 피드로
DEV Community · EffessDev · 2026-06-13 개발(SW)
Cover image for Indexes: Quickstart Using PostgreSQL (15 sec read)

EffessDev

Let’s consider a table user. When we execute a query to find Emily, we are actually going through each record, looking whether the name column equals Emily. Indexes comes in when you want to speed this up.

Let’s create an Index with the name idx_users_name (the name can be anything, and it doesn’t matter functionally):

CREATE INDEX idx_users_name ON users (name);

Enter fullscreen mode Exit fullscreen mode

Now when you run

SELECT * FROM users WHERE name = 'Emily';

Enter fullscreen mode Exit fullscreen mode

Postgres will use the index we just created (not by the name, the name is just for us) to execute that query, and the time complexity is reduced from O(n) to O(log n).

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다