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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:07:00+00:00 2026-06-07T11:07:00+00:00

I got a weird problem of MySQL index. I have a table views_video :

  • 0

I got a weird problem of MySQL index. I have a table views_video:

CREATE TABLE `views_video` (
  `video_id` smallint(5) unsigned NOT NULL,
  `record_date` date NOT NULL,
  `region` char(2) NOT NULL DEFAULT '',
  `views` mediumint(8) unsigned NOT NULL
  PRIMARY KEY (`video_id`,`record_date`,`region`),
  KEY `video_id` (`video_id`)
)

The table contains 3.4 million records.

I run the EXPLAIN on this query:

SELECT video_id, views FROM views_video where video_id <= 156

I got:

+----+-------------+-------------+-------+------------------+----------+---------+------+--------+-------------+
| id | select_type | table       | type  | possible_keys    | key      | key_len | ref  | rows   | Extra       |
+----+-------------+-------------+-------+------------------+----------+---------+------+--------+-------------+
|  1 | SIMPLE      | views_video | range | PRIMARY,video_id | video_id | 2       | NULL | 587984 | Using where |
+----+-------------+-------------+-------+------------------+----------+---------+------+--------+-------------+

But when I run the EXPLAIN on this query:

SELECT video_id, views FROM views_video where video_id <= 157

I got:

+----+-------------+-------------+------+------------------+------+---------+------+---------+-------------+
| id | select_type | table       | type | possible_keys    | key  | key_len | ref  | rows    | Extra       |
+----+-------------+-------------+------+------------------+------+---------+------+---------+-------------+
|  1 | SIMPLE      | views_video | ALL  | PRIMARY,video_id | NULL | NULL    | NULL | 3412892 | Using where |
+----+-------------+-------------+------+------------------+------+---------+------+---------+-------------+

video_id is from 1 to 1034. There is nothing special between 156 and 157.

What happens here?

* update *

I have added more data into the database. Now video_id is from 1 to 1064. And the table now has 3.8M records. And the difference become 114 and 115.

  • 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-07T11:07:02+00:00Added an answer on June 7, 2026 at 11:07 am

    I’m guessing that with 3.4 million records, and only 1064 possible entries for your key, your selectivity is very low. (In other words, there are many duplicates, which makes it far less useful as a key.) The optimizer is taking its best guess if it is more efficient to use the key or not. You’ve found a threshold for that decision.

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

Sidebar

Related Questions

ive got a really weird problem. i have no clue why its not working.
I am facing a weird problem. I have got a file called in which
I have been puzzled by this weird problem and it got me stuck. Please
i ve got a weird problem. My view : @{ ViewBag.Title = Index; }
I got this weird problem where System.Action cant be resolved when its not explicitly
I got a weird problem with CodeIgniter's URI segment system. When I have this
im a newbie to flash,and i hav got this really weird problem.i have created
I've got a weird problem that I can't understand... I have a simple HelloWorld
Got a weird problem here. I have created a template for a ListBox based
I got a weird problem. I have a program that (does many things but

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.