Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:52:26+00:00 2026-06-13T17:52:26+00:00

Would having a Composite Index be beneficial for something like this: SELECT * FROM

  • 0

Would having a Composite Index be beneficial for something like this:

SELECT * FROM a INNER JOIN b ON(a.id=b.id)
                INNER JOIN c ON(a.bar=c.id)
                INNER JOIN d ON(a.foo=d.id)

Index would be:

(a.id, a.bar, a.foo)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:52:28+00:00Added an answer on June 13, 2026 at 5:52 pm

    Only the leading edge of the index would be used (a.id), so only the INNER JOIN to b would benefit from the index… so the additional columns in the index (a.bar and a.foo) are not beneficial in the sample query posted.

    From the MySql documentation:

    MySQL cannot use the index to perform lookups if the columns do not
    form a leftmost prefix of the index. Suppose that you have the SELECT
    statements shown here:

    SELECT * 
    FROM tbl_name 
    WHERE col1=val1; 
    
    SELECT * 
    FROM tbl_name 
    WHERE col1=val1 AND col2=val2;
    
    SELECT * 
    FROM tbl_name 
    WHERE col2=val2; 
    
    SELECT * 
    FROM tbl_name 
    WHERE col2=val2 AND col3=val3; 
    

    If an index exists on (col1, col2, col3),
    only the first two queries use the index. The third and fourth queries
    do involve indexed columns, but (col2) and (col2, col3) are not
    leftmost prefixes of (col1, col2, col3).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody please help me with this difficulty I am having? I would like
Im having 2 different languages in my rails app and would like to be
I would just like to know if there is any advantage to having a
I am having several problems with JSONObjects and JSONArray. I would like to parse
From Previous Question I got some idea about having composite primary key in n-m
I'm using the Composite Application Library 's event aggregator, and would like to create
Hii, I need to develop an online quiz website that would be having MCQs.
Does anyone know about a SQL statements parser, in Java, that would allow having
How would i go about having my site know lets say IE User Visit's
I'm having trouble understanding why I would use a context.xml file to declare a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.