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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:50:18+00:00 2026-05-24T03:50:18+00:00

Ok, I have 2 million rows. Each has a billing date. i’m trying to

  • 0

Ok, I have 2 million rows. Each has a billing date. i’m trying to partition this out by that date. I’ve made partitions. I’ve checked /var/lib/mysql and the files are there, all of an appropriate file size so I can see something’s working. However when I do explian paritions select, its still telling me it’s using all the partitions. Am I doing someething wrong with how I built the table? Query the table? Indexes?

CREATE TABLE `billing_bil` (
`id_bil` mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
`bill_date_bil` date NOT NULL
PRIMARY KEY (`id`,`bill_date_bil`),
KEY `bill_date_bil` (`bill_date_bil`),
KEY `type_bill_date_bil` (`type_bil`,`bill_date_bil`)
) ENGINE=MyISAM AUTO_INCREMENT=2310168 DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE ( YEAR(bill_date_bil))
(PARTITION p0 VALUES LESS THAN (2008) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (2009) ENGINE = MyISAM,
PARTITION p2 VALUES LESS THAN (2010) ENGINE = MyISAM,
PARTITION p3 VALUES LESS THAN (2011) ENGINE = MyISAM,
PARTITION p4 VALUES LESS THAN (2012) ENGINE = MyISAM,
PARTITION p5 VALUES LESS THAN (2013) ENGINE = MyISAM,
PARTITION p6 VALUES LESS THAN (2014) ENGINE = MyISAM,
PARTITION p7 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */

EXPLAIN PARTITIONS SELECT SQL_NO_CACHE  id_bil FROM billing_bil WHERE bill_date_bil < '2010'
    id  select_type  table        partitions               type    possible_keys  key      key_len  ref        rows  Extra                   

 1  SIMPLE       billing_bil  p0,p1,p2,p3,p4,p5,p6,p7  index   bill_date_bil  PRIMARY  6        (NULL)  2310167  Using where; Using index

I was expecting that query to use p0 and p1 only, but it uses all of them.

  • 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-24T03:50:19+00:00Added an answer on May 24, 2026 at 3:50 am

    Your partitions are fine. Your query’s WHERE clause is where the problem lies. When I ran the EXPLAIN PARTITIONS statement on MySQL 5.5, there were two warnings:

    +---------+------+------------------------------------------------------------------+
    | Level   | Code | Message                                                          |
    +---------+------+------------------------------------------------------------------+
    | Warning | 1292 | Incorrect date value: '2010' for column 'bill_date_bil' at row 1 |
    | Warning | 1292 | Incorrect date value: '2010' for column 'bill_date_bil' at row 1 |
    +---------+------+------------------------------------------------------------------+
    

    If you change your query to use a real date like so, it will use the partitions (I didn’t include your indexes in my CREATE TABLE statement, which is why they aren’t being used):

    mysql> EXPLAIN PARTITIONS SELECT SQL_NO_CACHE  id_bil FROM billing_bil WHERE bill_date_bil < '2010-01-01';
    +----+-------------+-------------+------------+--------+---------------+------+---------+------+------+-------+
    | id | select_type | table       | partitions | type   | possible_keys | key  | key_len | ref  | rows | Extra |
    +----+-------------+-------------+------------+--------+---------------+------+---------+------+------+-------+
    |  1 | SIMPLE      | billing_bil | p0,p1,p2   | system | NULL          | NULL | NULL    | NULL |    1 |       |
    +----+-------------+-------------+------------+--------+---------------+------+---------+------+------+-------+
    

    I’m guessing it uses partition p2 because MySQL supports partial dates (2010-00-00 is less than 2010-01-01): How to deal with "partial" dates (2010-00-00) from MySQL in Django?

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

Sidebar

Related Questions

I have a relatively large database tables (just under a million rows) that has
I have a table with about 35 million rows. each has about 35 integer
I have a table that has about 1/2 million records in it. Each month
I have a million rows in a database table. For each row I have
I have two tables with 10-20 million rows that have GUID primary keys and
I have a MySQL table from a third-party application that has millions of rows
I have a SQL Server (2005) table which has nearly 100+ million rows in
Assuming I have 2 large tables with well over 10 Million Rows in each
I have 1 million rows in MySql table temp and wish to multiply column
I have 3 million rows customers.csv file. When I import it in SQL 2008,

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.