今日已更新 412 条资讯 | 累计 19972 条内容
关于我们

Indexes: Quickstart Using PostgreSQL (15 sec read)

EffessDev 2026年06月12日 23:35 3 次阅读 来源:Dev.to

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 ); Now when you run SELECT * FROM users WHERE name = 'Emily' ; 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) .

本文内容来源于互联网,版权归原作者所有
查看原文