Indexes Flashcards

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Most common algorithm type of index?

A

Binary-tree`

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Are PRIMARY KEY columns indexed by default?

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Syntax for creating a single-column INDEX

A

CREATE INDEX index_name on table_name (column_name);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the complexity of a binary tree?

A

O(log(n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Drawbacks of creating an index

A
  1. Increases the memory usage of your database
  2. Slows down your insert speed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How SQL injections are prevented?

A

SQL library that sanitizes SQL inputs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly