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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:01:29+00:00 2026-05-19T14:01:29+00:00

Im trying to understand indexes better for when I use Mysql. One issue is

  • 0

Im trying to understand indexes better for when I use Mysql. One issue is Im still having a hard time to determine what type of index I should use such as individual indexes, multi column indexes, covering indexes etc.

One question I have is, is there a general rule to decide what type of indexes to use? When I design my database layout I dont know exactly what all queries will be used until the application is done being built. For one table I could query on one or multiple fields as well as query it for reporting. So if I query a table like so:

SELECT * FROM table1 WHERE field1 = this AND field2 = that GROUP BY field3 ORDER BY field4

Would I create a multiple column index on field1,field3,field3 and field4?

Also what if I have a different query on the same table like:

SELECT * FROM table1 WHERE field1 = this and field3 = that

If I had the multiple column index from the first query will that same index work for the second query since field1 is on the farthest left of the index?

And another question I had was is there a specific order mysql looks for indexes? So for multiple column or a covering index do I add indexes in order of the where clause? Then anything in group clause then anything in order clause? Or does mysql automatically do this?

Sorry for all the questions, just looking for help on this.

  • 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-05-19T14:01:30+00:00Added an answer on May 19, 2026 at 2:01 pm
    • Engine

    First you have to decide which Engine you want to use for a given table

    1. InnoDB is preferable (transactions…) but does not offer fulltext index
    2. If you need fulltext index, you have to chose MyISAM

    (Full text index keeps an index based on words in a column)

    • Tables

    You have to know that MySQL uses only one index per table maximum in a join. So, don’t expect MySQL to combine two indexes of a given table.

    • Multi-columns

    Chose the order of the column based on the queries, provided that MySQL can use the top of the index if necessary

    For instance

      CREATE INDEX myindex ON mytable (col1,col2,col3)
    

    MySQL can use (col1), (col1,col2) and (col1,col2,col3) as index. So to answer your question, your index should be created on

      (field1,field3,field2,field4).
    

    since your two queries needs (field1,field3) and (field1,field2,field3,field4).

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

Sidebar

Related Questions

So I'm trying to understand how SQL Server makes use of indexes on tables
Trying to understand why you can't use sql_variant for the value type when using
Trying to understand Ruby a bit better, I ran into this code surfing the
I'm trying to understand the performance of database indexes in terms of Big-O notation.
I am not an expert with MySQL, and I am trying to understand why
I am just getting started with MongoDB and trying to understand how indexes work.
I'm trying to get my head around to understand how to use closures in
Trying to understand the use of verifySet etc... but unless I do a workaround
Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults

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.