What is a database index and how does a B-tree index work?
What is a database index and how does a B-tree index work?
An index is a separate, sorted data structure that lets the database find rows without reading the whole table, like the index of a book. The default type in every major engine is the B-tree (strictly a B+tree).
CREATE INDEX idx_orders_customer ON orders (customer_id);
SELECT * FROM orders WHERE customer_id = 42; -- uses the index instead of scanning every row
O(log n).Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.