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

The Archive Base Latest Questions

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

Please consider following schema CREATE table articles ( id Int UNSIGNED NOT NULL AUTO_INCREMENT,

  • 0

Please consider following schema

CREATE table articles (
    id Int UNSIGNED NOT NULL AUTO_INCREMENT,
    cat_id Int UNSIGNED NOT NULL,
    status Int UNSIGNED  NOT NULL,
    date_added Datetime,
    Primary Key (id)) ENGINE = InnoDB;

CREATE INDEX cat_list_INX ON articles (cat_id, status, date_added);
CREATE INDEX categories_list_INX ON articles (cat_id, status);

I have written following two queries which can be completely satisfied by the above two indicies but MySQL is putting where in extra column.

mysql> EXPLAIN SELECT cat_id FROM articles USE INDEX (cat_list_INX) WHERE cat_id=158 AND status=2 ORDER BY date_added DESC LIMIT 500, 5;
+----+-------------+----------+------+---------------+--------------+---------+-------------+-------+--------------------------+
| id | select_type | table  ref         |   | type | possible_keys | key          | key_len | rows  | Extra                    |
+----+-------------+----------+------+---------------+--------------+---------+-------------+-------+--------------------------+
|  1 | SIMPLE      | articles | ref  | cat_list_INX  | cat_list_INX | 5       | const,const | 50698 | Using where; Using index |
+----+-------------+----------+------+---------------+--------------+---------+-------------+-------+--------------------------+


mysql> EXPLAIN SELECT cat_id FROM articles USE INDEX (categories_list_INX) WHERE cat_id=158 AND status=2;
+----+-------------+----------+------+---------------------+---------------------+---------+-------------+-------+--------------------------+
| id | select_type | tab key                 |le    | type | possible_keys       | key_len | ref         | rows  | Extra                    |
+----+-------------+----------+------+---------------------+---------------------+---------+-------------+-------+--------------------------+
|  1 | SIMPLE      | articles | ref  | categories_list_INX | categories_list_INX | 5       | const,const | 52710 | Using where; Using index |
+----+-------------+----------+------+---------------------+---------------------+---------+-------------+-------+--------------------------+

As far as I know where requires an additional disk seek. Why it’s not just using index?

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

    The first query is filtering records at the mysql level outside of the storage engine because of your “ORDER BY” clause using date_added field.

    This can be mitigated by moving the date_added field first in the index like this

    CREATE INDEX cat_list_INX ON articles (date_added, cat_id, status);
    

    The 2nd query – my version of mysql is not showing a “Using where” – I would not expect to either – maybe its because I have no records.

    mysql> EXPLAIN SELECT cat_id FROM articles USE INDEX (categories_list_INX) WHERE cat_id=158 AND status=2;
    +----+-------------+----------+------+---------------------+---------------------+---------+-------------+------+-------------+
    | id | select_type | table    | type | possible_keys       | key                 | key_len | ref         | rows | Extra       |
    +----+-------------+----------+------+---------------------+---------------------+---------+-------------+------+-------------+
    |  1 | SIMPLE      | articles | ref  | categories_list_INX | categories_list_INX | 8       | const,const |    1 | Using index |
    +----+-------------+----------+------+---------------------+---------------------+---------+-------------+------+-------------+
    1 row in set (0.00 sec)
    

    Extra column info from High Performance MySQL:

    Using Index: This indicates that MySQL will use a covering index to avoid accessing the table. Don’t confuse covering indexes with the index access type.

    Using Where: This means the MySQL server will post-filter rows after the storage engine retrieves them. Many WHERE conditions that involve columns in an index can be checked by the storage engine when (and if) it reads the index, so not all queries with a WHERE clause will show “Using where”. Sometimes the presence of “Using where” is a hint that the query can benefit from different indexing.

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

Sidebar

Related Questions

Please consider the following scripts. Create Table: IF OBJECT_ID('Colortable') IS NOT NULL DROP TABLE
Please consider the following simple use case: public class Foo { public virtual int
Please consider the following table (created using a corresponding entity) request ------- id requestor
Please consider the following HTML: <td> Some Text <table>.....</table> </td> I need to manipulate
Please consider the following table 'mmm': select * from mmm; Output: +-------+-------+------+ | texto
Please Consider the following table : As you can see the Name column has
Please consider the following code and comments: Console.WriteLine(1 / 0); // will not compile,
Please consider the following snippet: public interface MyInterface { public int getId(); } public
please consider following code #include <iostream> using namespace std; class Digit { private: int
Please consider following code: 1. uint16 a = 0x0001; if(a < 0x0002) { //

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.