Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your partitions are fine. Your query's <code>WHERE</code> clause is where the problem lies. When I ran the <code>EXPLAIN PARTITIONS</code> statement on MySQL 5.5, there were two warnings:</p> <pre><code>+---------+------+------------------------------------------------------------------+ | 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 | +---------+------+------------------------------------------------------------------+ </code></pre> <p>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 <code>CREATE TABLE</code> statement, which is why they aren't being used):</p> <pre><code>mysql&gt; EXPLAIN PARTITIONS SELECT SQL_NO_CACHE id_bil FROM billing_bil WHERE bill_date_bil &lt; '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 | | +----+-------------+-------------+------------+--------+---------------+------+---------+------+------+-------+ </code></pre> <p>I'm guessing it uses partition <code>p2</code> because MySQL supports partial dates (<code>2010-00-00</code> is less than <code>2010-01-01</code>): <a href="https://stackoverflow.com/questions/2971198/how-to-deal-with-partial-dates-2010-00-00-from-mysql-in-django">How to deal with &quot;partial&quot; dates (2010-00-00) from MySQL in Django?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload