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

  • Home
  • SEARCH
  • 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 7585057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:04:51+00:00 2026-05-30T19:04:51+00:00

Consider fetching data with SELECT * FROM table WHERE column1=’XX’ && column2=’XX’ Mysql will

  • 0

Consider fetching data with

SELECT * FROM table WHERE column1='XX' && column2='XX'

Mysql will filter the results matching with the first part of WHERE clause, then with the second part. Am I right?

Imagine the first part match 10 records, and adding the second part filters 5 records. Is it needed to INDEX the second column too?

  • 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-30T19:04:52+00:00Added an answer on May 30, 2026 at 7:04 pm

    Indexes are optional in MySQL, but they can increase performance.

    Currently, MySQL can only use one index per table select, so with the given query, if you have an index on both column1 and column2, MySQL will try to determine the index that will be the most beneficial, and use only one.

    The general solution, if the speed of the select is of utmost importance, is to create a multi-column index that includes both columns.

    This way, even though MySQL could only use one index for the table, it would use the multi-column index that has both columns indexed, allowing MySQL to quickly filter on both criteria in the WHERE clause.

    In the multi-column index, you would put the column with the highest cardinality (the highest number of distinct values) first.

    For even further optimization, “covering” indexes can be applied in some cases.

    Note that indexes can increase performance, but with some cost. Indexes increase memory and storage requirements. Also, when updating or inserting records into a table, the corresponding indexes require maintenance. All of these factors must be considered when implementing indexes.

    Update: MySQL 5.0 can now use an index on more than one column by merging the results from each index, with a few caveats.

    The following query is a good candidate for Index Merge Optimization:

    SELECT * FROM t1 WHERE key1=1 AND key2=1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider an indexed MySQL table with 7 columns, being constantly queried and written to.
Consider the following 2 queries: select tblA.a,tblA.b,tblA.c,tblA.d from tblA where tblA.a not in (select
I'm currently creating a C# program which will be fetching some data over https
PLATFORM: PHP, mySQL & jQuery WHAT I HAVE: I have a Database table. Within
I have a page which is fetching data from a webservice using async call.
Consider the Oracle emp table. I'd like to get the employees with the top
Consider 3 regex expressions designed to remove non Latin characters from the string. String
I have 2 tables. One table is 'headings' & contains Headings and the other
Consider the following set up: - SomeFilter extends Filter - Filter implements Runnable -
Consider this in C#: int[] a = new int[1024]; All integers will be set

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.