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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:26:39+00:00 2026-05-23T03:26:39+00:00

I have a simple mysql table I want to use for daily stat tracking.

  • 0

I have a simple mysql table I want to use for daily stat tracking. After putting some information into it and testing out a samply query I’d use on it, it’s not using my index! I can’t figure out why.

I tried putting in more test data – 200 rows. I also tried changing select * to select created,value1. No dice.

mysql> show create table stat_general\G
*************************** 1. row ***************************
       Table: stat_general
Create Table: CREATE TABLE `stat_general` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `nameid` smallint(6) NOT NULL,
  `value1` int(11) NOT NULL,
  `value2` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `created` (`created`,`nameid`,`value2`)
) ENGINE=MyISAM AUTO_INCREMENT=49 DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

mysql> select * from stat_general;
+----+---------------------+--------+--------+--------+
| id | created             | nameid | value1 | value2 |
+----+---------------------+--------+--------+--------+
|  1 | 2011-06-09 09:43:41 |      1 | 511803 |   NULL |
|  2 | 2011-06-09 09:43:41 |      2 |     44 |   NULL |
|  3 | 2011-06-09 09:43:41 |      3 |   9128 |   NULL |
|  4 | 2011-06-09 09:43:41 |      4 |    219 |   NULL |
|  5 | 2011-06-09 09:43:41 |      5 |      0 |   NULL |
|  6 | 2011-06-09 09:43:41 |      6 |      0 |   NULL |
|  7 | 2011-06-09 09:43:41 |      7 |      0 |   NULL |
|  8 | 2011-06-09 09:43:41 |      8 |      0 |   NULL |
|  9 | 2011-06-09 09:43:41 |      9 |      0 |   NULL |
| 10 | 2011-06-09 09:43:41 |     10 |    140 |   NULL |
| 11 | 2011-06-09 09:43:41 |     11 |      0 |   NULL |
| 12 | 2011-06-09 09:43:41 |     12 |    146 |   NULL |
| 13 | 2011-06-09 09:43:41 |     13 |      0 |   NULL |
| 14 | 2011-06-09 09:43:41 |     14 |      1 |   NULL |
| 15 | 2011-06-09 09:43:41 |     15 |   8981 |   NULL |
| 16 | 2011-06-09 09:43:41 |     16 |      1 |   -127 |
| 17 | 2011-06-09 09:43:41 |     16 |      2 |     -2 |
| 18 | 2011-06-09 09:43:41 |     16 |    939 |     -1 |
| 19 | 2011-06-09 09:43:41 |     16 |    146 |      1 |
| 20 | 2011-06-09 09:43:41 |     16 |   8011 |      3 |
| 21 | 2011-06-09 09:43:41 |     16 |     28 |    127 |
| 22 | 2011-06-09 09:43:41 |     16 |      1 |    128 |
| 23 | 2011-06-09 09:43:41 |     17 |    146 |      1 |
| 24 | 2011-06-09 09:43:41 |     18 |    146 |      1 |
| 25 | 2011-06-09 09:44:08 |      1 | 511803 |   NULL |
| 26 | 2011-06-09 09:44:08 |      2 |     44 |   NULL |
| 27 | 2011-06-09 09:44:08 |      3 |   9128 |   NULL |
| 28 | 2011-06-09 09:44:08 |      4 |    219 |   NULL |
| 29 | 2011-06-09 09:44:08 |      5 |      0 |   NULL |
| 30 | 2011-06-09 09:44:08 |      6 |      0 |   NULL |
| 31 | 2011-06-09 09:44:08 |      7 |      0 |   NULL |
| 32 | 2011-06-09 09:44:08 |      8 |      0 |   NULL |
| 33 | 2011-06-09 09:44:08 |      9 |      0 |   NULL |
| 34 | 2011-06-09 09:44:08 |     10 |    140 |   NULL |
| 35 | 2011-06-09 09:44:08 |     11 |      0 |   NULL |
| 36 | 2011-06-09 09:44:08 |     12 |    146 |   NULL |
| 37 | 2011-06-09 09:44:08 |     13 |      0 |   NULL |
| 38 | 2011-06-09 09:44:08 |     14 |      1 |   NULL |
| 39 | 2011-06-09 09:44:08 |     15 |   8981 |   NULL |
| 40 | 2011-06-09 09:44:08 |     16 |      1 |   -127 |
| 41 | 2011-06-09 09:44:08 |     16 |      2 |     -2 |
| 42 | 2011-06-09 09:44:08 |     16 |    939 |     -1 |
| 43 | 2011-06-09 09:44:08 |     16 |    146 |      1 |
| 44 | 2011-06-09 09:44:08 |     16 |   8011 |      3 |
| 45 | 2011-06-09 09:44:08 |     16 |     28 |    127 |
| 46 | 2011-06-09 09:44:08 |     16 |      1 |    128 |
| 47 | 2011-06-09 09:44:08 |     17 |    146 |      1 |
| 48 | 2011-06-09 09:44:08 |     18 |    146 |      1 |
+----+---------------------+--------+--------+--------+
48 rows in set (0.00 sec)

mysql> select * from stat_general where created>'2011-06-09 9:44' AND nameid=1;
+----+---------------------+--------+--------+--------+
| id | created             | nameid | value1 | value2 |
+----+---------------------+--------+--------+--------+
| 25 | 2011-06-09 09:44:08 |      1 | 511803 |   NULL |
+----+---------------------+--------+--------+--------+
1 row in set (0.00 sec)

mysql> explain select * from stat_general where created>'2011-06-09 9:44' AND nameid=1;
+----+-------------+--------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table        | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+----+-------------+--------------+------+---------------+------+---------+------+------+-------------+
|  1 | SIMPLE      | stat_general | ALL  | created       | NULL | NULL    | NULL |   48 | Using where |
+----+-------------+--------------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
  • 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-23T03:26:40+00:00Added an answer on May 23, 2026 at 3:26 am

    Two reasons:

    First and foremost, your table is too small. With this few rows, it’s faster to open the entire table and filter the rows one by one irrespective of the query.

    Next, even if you had more rows with very similar data, your current index is not selective enough. In such situations, it’s not worth randomly opening disk pages; it’ll be faster to open the them sequentially and filter invalid rows out.

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

Sidebar

Related Questions

I use PHP, MySQL and Zend Framework. I have some simple tables with simple
I have a simple table in MySql whose raison-d'être is to store logs. The
I'm using embedded SQL with Java. I have a simple table where I want
How can I sort into MySQL in AlphaNumeric order; Suppose I have a table
I have a simple webform that will allow unauthenticated users to input their information,
Fairly simple question: Say I want to use 30 percent of the rows in
I have a mysql table containing news data and categories and i'm trying to
Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ |
In MySQL, I have a simple "SELECT * FROM foo" query. I would like
Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)

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.