Curated from: use-the-index-luke.com
Ideas, facts & insights covering these topics:
6 ideas
·267 reads
4
6
Explore the World's Best Ideas
Join today and uncover 100+ curated journeys from 50+ topics. Unlock access to our mobile app with extensive features.
What is it?:
What is it good for?:
Does it have any disadvantage?:
Creating index syntax in POSTGRESQL:
CREATE INDEX e_idx ON users (email)
10
115 reads
Terminology:
How indexes work:
When to use Single-Column Indexes:
Index on (x):
SELECT * FROM table WHERE x = 11
When to use Multi-Column Indexes:
Index on (t, x):
SELECT * FROM table WHERE t = 9 and x = 11
9
57 reads
Order of the columns matter.
The index is useless if the first column doesn't appear in the WHERE clause.
Example 1:
An index on (t, x) will not be used in this query:
Example 2:
However an index on (x, t) will be used in both of these queries:
SELECT * FROM table WHERE x = 11
and
SELECT * FROM table WHERE t = 9 and x = 11
9
24 reads
Wrapping the indexed column in a function nullifies the index almost completely.
Index:
CREATE INDEX e_idx ON users (email)
Query:
SELECT COUNT(*)
FROM users
WHERE UPPER(email) = '[email protected]'
This will read the full index end to end which is only slightly better than reading full table.
8
25 reads
When it can be used:
1. Exact matches:
2. Using wild card character (% or _) at the end:
3. Less effective, but still useful, using wild card character in the middle:
When it is useless:
When wild card character is used in the beginning:
8
20 reads
8
26 reads
IDEAS CURATED BY
Similar ideas
13 ideas
How to Excel in Tech Without Learning to Code
future.a16z.com
8 ideas
6 Life Lessons from Link – The Hero of Time
zelda.fandom.com
Read & Learn
20x Faster
without
deepstash
with
deepstash
with
deepstash
Personalized microlearning
—
100+ Learning Journeys
—
Access to 200,000+ ideas
—
Access to the mobile app
—
Unlimited idea saving
—
—
Unlimited history
—
—
Unlimited listening to ideas
—
—
Downloading & offline access
—
—
Supercharge your mind with one idea per day
Enter your email and spend 1 minute every day to learn something new.
I agree to receive email updates