Order in Multi-Column Index Matters - Deepstash
Order in Multi-Column Index Matters

Order in Multi-Column Index Matters

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:

  • SELECT * FROM table WHERE x = 11

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

23 reads

CURATED FROM

IDEAS CURATED BY

adn

Love problem solving and sport.

Similar ideas to Order in Multi-Column Index Matters

Single vs Concatenated Indexes

Single vs Concatenated Indexes

Terminology:

  • Single Index = Single-Column Index
  • Concatenated Index = Multi-Column Index

How indexes work:

  • Index is used to find data fast, therefore it looks for the WHERE claus...

PR helps you show off your expertise

PR helps you show off your expertise

Founding a startup doesn't make you an expert in your field. If nobody knows about your expertise, investors might see you as an outsider. 

Investing in PR, you are investing in building a portfolio of your public opinions, mentions, and columns in the outlets that matter i...

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.

Email

I agree to receive email updates