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 9080609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:06:42+00:00 2026-06-16T20:06:42+00:00

I very often search the table posts for values in the columns user +

  • 0

I very often search the table posts for values in the columns user+status and user+time.

SELECT * FROM `posts` WHERE `user`='xxx' and `status`='active'
SELECT * FROM `posts` WHERE `user`='xxx' and `time`>...

Thus I have set up two indices (user, status) and (user, time)

I’m aware, that writing processes are slowed down the more indices need to be updated. But I think in this case it is useful to have both indices, since reading operations outnumber writing operations by far.

Anyway, PHPMyAdmin gives a Warning saying “More than one index has been created for the column user”. Can I just ignore this warning? I checked the WordPress DB tables and saw that they have put a column at the second position, if it already had an index.

comment_approved_date_gmt = INDEX(comment_approved, comment_date_gmt)
comment_date_gmt = INDEX(comment_date_gmt)

Why don’t they use only one two column index (INDEX(comment_date_gmt, comment_approved)), that would save INDEX(comment_date_gmt)? and why is it disadvantageous to have two indices starting with the same column-name?

Is there a general rule, which column should go first in my query? For example the one with the lowest number of different entries (e.G. status) and afterwards the one with a higher number of different values (e.g. user names)

  • 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-16T20:06:43+00:00Added an answer on June 16, 2026 at 8:06 pm

    Yes, the order of columns in an index matters.

    Think of an analogy to a telephone book. It’s like an index on (last_name, first_name). Looking up a person by last name, you use the sorted order of the phone book to help you find them quickly.

    But if you only know the person’s first name, they are scattered throughout the book. To find one, you’d have to search the book page by page.

    Yes, indexes can be redundant.

    Any query that is searching for last_name can use a single-column index on (last_name), or it can get the same benefit from a two-column index on (last_name, first_name). So why create both indexes?

    There’s a tool pt-duplicate-key-checker that can help you identify redundant indexes. I’ve never come across a database that didn’t have at least a few such indexes.

    phpMyAdmin is wrong.

    If phpMyAdmin is warning about the indexes (user, status) and (user, time), then it’s being over-zealous, because these indexes are not redundant with respect to each other. Basically, an index is redundant if its columns comprise a left-prefix of the columns in another index. So an index (A) is redundant with respect to an index (A, B), but an index (A, C) is distinct from (A, B) and both may be used by different queries.

    PS: I cover these points and more in my presentation How to Design Indexes, Really.

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

Sidebar

Related Questions

I use search sites very often. And in 99% of cases search results that
I'm a chinese internet user. Google/Yahoo search engines are very unstable in my country.
Very often I use Dictionary<TKey, TValue> type to store ehh...dictionary type of values, e.g.
very often I like to have my movieclip code inside the movieclip (on a
Very often when Visual Studio generates code (for example generating an event handler stub)
Very often, I just create a new folder and test things out in there.
Very often, I find myself using a callback function and I don't have its
Very often, it's natural to need to specify a CSS style for all elements
Just a simple but very often needed operation - how to prepend a string
I don't use Excel very often, but I'm hoping there is a fairly straightforward

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.