Take the 2-minute tour ×
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. It's 100% free, no registration required.

Is there a way to select the partition name where a specified record actually lives in? The idea is something like:

SELECT <PARTITION_NAME> FROM mytable WHERE <where_condition>

I found a similar question for SQL Server: Get a record's current partition, but not for MySQL.

share|improve this question
    
Hi, you can't select the partition name in one SELECT statement. Ue the system table "information_schema.partitions", filter on TABLE_SCHEMA and TABLE_NAME. Then play with PARTITION_DESCRIPTION to find your data. Give us your table structure and your partition method if you need some help. –  Maxime FOUILLEUL May 27 '13 at 15:23
    
Thank you for your answer, the way you propose works well but is quite slow in my case, especially considering dynamically created queries. I would need to select the partition attribute for each query, then find the corresponding partition in INFORMATION_SCHEMA.partitions. I need the partition information to speed up a SELECT * FROM <table> PARTITION <partition>, so quickly (sub)selecting the partition would be really helpful. –  MaoPU May 27 '13 at 18:56

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.