How do database engines manage to be so much faster at lookup / aggregation than your code?

164 views

How do database engines manage to be so much faster at lookup / aggregation than your code?

In: 1

4 Answers

Anonymous 0 Comments

SQL Server uses a database engine that is built around a computer science data structure called a B-tree.

The old way of searching for something required one to step through every single element in a list until you reached the key you were looking for. In the worst case, with N elements, the thing you were looking for would be at the very end of the list requiring you to walk though N elements.

A B tree is logically structured in an ordered way such that you can traverse a tree of N elements and find the thing you were looking for in around Log N steps. For very large lists Log N is significantly faster than N.

You are viewing 1 out of 4 answers, click here to view all answers.