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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:50:45+00:00 2026-05-26T21:50:45+00:00

I am using MySQl database. I know if I create a index for a

  • 0

I am using MySQl database.

I know if I create a index for a column, it will be fast to query data from a table by using that column index. But, I still have the following questions:

(suppose I have a table named cars, there is a column named country, and I have created index for country column)

  1. I know for example the query SELECT * FROM cars WHERE country='japan'will use the index on column country to query data which is fast. How about != operation? will SELECT * FROM cars WHERE country!='japan'; also use index to query data?

  2. Does WHERE ... IN ... operation use index to query data? For example SELECT * FROM cars WHERE country IN ('japan','usa','sweden');

  • 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-26T21:50:46+00:00Added an answer on May 26, 2026 at 9:50 pm

    You can use EXPLAIN SELECT to find out if your query uses an index or not.

    For example:

    EXPLAIN SELECT * 
    FROM A 
    WHERE foo NOT IN (1,4,5,6);
    

    Might yield:

    +----+-------------+-------+------+---------------
    | id | select_type | table | type | possible_keys 
    +----+-------------+-------+------+---------------
    |  1 | SIMPLE      | A     | ALL  | NULL          
    +----+-------------+-------+------+---------------
    
    +------+---------+------+------+-------------+
    | key  | key_len | ref  | rows | Extra       |
    +------+---------+------+------+-------------+
    | NULL | NULL    | NULL |    2 | Using where |
    +------+---------+------+------+-------------+
    

    In this case, the query had no possible_keys and therefore used no key to do the query. It’s the key column you’d be interested in.

    More information here:

    • http://dev.mysql.com/doc/refman/5.0/en/explain.html
    • http://dev.mysql.com/doc/refman/5.0/en/optimization-indexes.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to export data and structure from MySQL database using PHP. I know
i am adding data from vba excel using adodb into a mysql database everything
Fortunately, I know how to fetch data from the database, That's not a problem.
I installed MySql on my own machine. I created database, create table, ... using
I randomly get a row from a mysql-database using php (ugly random, I know).
I have a client that wants to connect to his MySQL database using Dial-up/Modem
Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The
I am using XMLWriter to create an XML output of my MySQL Database, and
I am trying to create a go-moku game using jquery,php, and mysql database. I
I am using a MySQL database. I know PostgreSQL and SQL Server supports partial

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.