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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:05:16+00:00 2026-06-15T18:05:16+00:00

Using MySQL version 5.5.28, I have a table defined as such: CREATE TABLE IF

  • 0

Using MySQL version 5.5.28,

I have a table defined as such:

CREATE TABLE IF NOT EXISTS `groups` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(80) NOT NULL,
  `desc` text NOT NULL,
  `permissions` varchar(80) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 ;

As you can see, it’s pretty simple. I have a primary key on the id field. Now, I query against it using something like this:

SELECT permissions FROM groups WHERE id IN ('9', '8', '6','14','11','7','5');

Unfortunately it refuses to use the key, and it shows up in my slow query log.

Performing EXPLAIN on it provides:

mysql> EXPLAIN SELECT permissions FROM groups WHERE id IN ('9', '8', '6','14','11','7','5');
+----+-------------+--------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table  | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+----+-------------+--------+------+---------------+------+---------+------+------+-------------+
|  1 | SIMPLE      | groups | ALL  | PRIMARY       | NULL | NULL    | NULL |   16 | Using where |
+----+-------------+--------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)

It only has less than 20 rows in the entire table, so I get why it wouldn’t likely use the index. But, why would this be a “slow query” for MySQL?

  • 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-15T18:05:18+00:00Added an answer on June 15, 2026 at 6:05 pm

    With a small number of rows, full scan will almost always be the fastest way to access the table. Also, selectivity important – even if id is unique, the query returns around 30% of all rows (assuming you have 20). It appears in slow query log not because it’s slow, but because it doesn’t use index (it should be an option to control that behaviour, I just don’t remember it from the top of my head)

    Update I just double checked, option is log-queries-not-using-indexes

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

Sidebar

Related Questions

I created this using MySQL WorkBench CREATE TABLE IF NOT EXISTS `bakasura_new`.`cities` ( `id`
I have the following script to create a table in MySQL version 5.1 which
I have a very simple table CREATE TABLE IF NOT EXISTS `largecache` ( `id`
MySQL version 5.1.63-cll Using phpmyadmin to edit So i have this table ps_layered_price_index i
Using MySQL, I have a simple table that logs the IP Address that users
I am using MYSQL 5.1. When i am going create a table, it throws
I have a setup where I have a MySQL DB using Amazon's RDS (version
I am using MySQL DB. I have a cars table, by describing this table
I am using the mysql admin GUI tool to create a table. Here is
Currently using MySQL version 5.1.6 This is my first real world build and so

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.