Bug #62351 How to check that partition pruning occurs
Submitted: 5 Sep 2011 13:21 Modified: 5 Sep 2011 13:25
Reporter: Yann Neuhaus Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S4 (Feature request)
Version:5.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: How to check that partition pruning occurs

[5 Sep 2011 13:21] Yann Neuhaus
Description:
Hi,

Would it be possible to explain how we can see the used partitions while partition pruning occurs. For instance "explain" statement showing that only one partition is scanned.

Let me know.

Best Regards

Yann

How to repeat:
I have partitioned table and I do not see that partitioning pruning occurs in the explain plan :

mysql> explain select count(*) from sales_range where year(sales_date) = '2008';
+----+-------------+-------------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table       | type | possible_keys | key  | key_len | ref  | rows    | Extra       |
+----+-------------+-------------+------+---------------+------+---------+------+---------+-------------+
|  1 | SIMPLE      | sales_range | ALL  | NULL          | NULL | NULL    | NULL | 1000000 | Using where |
+----+-------------+-------------+------+---------------+------+---------+------+---------+-------------+
1 row in set (0.00 sec)

The tables sales range contains 100000 rows and looks like :

CREATE TABLE IF NOT EXISTS sales_range
 (salesman_id   INT, 
  product_id    INT, 
  sales_amount  INT, 
  sales_date    DATE) engine=MyISAM
PARTITION BY RANGE(YEAR(sales_date))
(
PARTITION sales_year_2008 VALUES LESS THAN (2009),
PARTITION sales_year_2009 VALUES LESS THAN (2010),
PARTITION sales_year_2010 VALUES LESS THAN (2011),
PARTITION sales_year_2011 VALUES LESS THAN (2012)
);

Suggested fix:
The explain feature should show when partition prunning occurs isn't it ?

No reference to the way how to monitor partition pruning in the doc.
[5 Sep 2011 13:25] Yann Neuhaus
Sorry , I just saw the "explain partitions". Sorry for disturbing you.

Best Regards

Yann

----