Indexes Flashcards
(8 cards)
1
Q
What is an INDEX?
A
An index is an in-memory structure that ensures that queries we run on a database are performant
2
Q
Most common algorithm type of index?
A
Binary-tree`
3
Q
Are PRIMARY KEY columns indexed by default?
A
TRUE
4
Q
Syntax for creating a single-column INDEX
A
CREATE INDEX index_name on table_name (column_name);
5
Q
What is the complexity of a binary tree?
A
O(log(n))
6
Q
Drawbacks of creating an index
A
- Increases the memory usage of your database
- Slows down your insert speed
7
Q
Syntax for creating a multi-column INDEX
A
CREATE INDEX first_name_last_name_age_idx
ON users (first_name, last_name, age);
8
Q
How SQL injections are prevented?
A
SQL library that sanitizes SQL inputs