Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this table:

      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `user_id` int(11) unsigned NOT NULL,
      `group_id` smallint(5) unsigned NOT NULL,
      PRIMARY KEY (`group_id`,`user_id`),
      KEY `id` (`id`),
      KEY `user_id` (`user_id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5496 ;

when run this query:

EXPLAIN SELECT `UserGroup`.`user_id` FROM   `usergroups` AS `UserGroup` WHERE  `UserGroup`.`group_id` = 1 limit 30

its out put is:

1       SIMPLE        UserGroup      ref  PRIMARY  PRIMARY  2        const  543      Using index

I think something is wrong! because it affected 543 rows but I think it should affect 30 rows at maximum. Is it true?

share|improve this question
up vote 2 down vote accepted

Limit does have an impact on how many rows are selected/affected. 543 is just the number of rows which match the joins and the where clause.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.