1. What query use Index

image.png

2. Types of index

2.1. Partial Index

CREATE INDEX ON orders (placed_at) WHERE status = 'pending';

2.2. Covering index

CREATE INDEX ON orders (customer_id) INCLUDE (status, total_cents)Tatipelly, Sunil. Senior Backend Engineer Interview Guide: The Complete Guide to Backend Programming, APIs, Databases, System Design, Distributed Systems, and Production Engineering Interviews (p. 192). (Function). Kindle Edition. 

2.3. Expression index

CREATE INDEX ON customers (LOWER(email));

So:

WHERE LOWER(email) = '[email protected]'

can use it.

But

WHERE email = '[email protected]'

can not use it.

3. Sargability

4. Reading a query plan