How to specialize a generic enum in Swift?

MySQL Performance: What's the best way to partition a table on ENUM?

  • I have an large table (50+ GB) that I need to partition on an ENUM column. Unfortunately, MySQL doesn't support ENUM-based partitioning with "PARTITON BY LIST" รข€” see MySQL bug #39548: http://bugs.mysql.com/bug.php?id=39548. (No, I can't change the ENUM to a tinyint and store the mapped text values elsewhere.) Is there a preferred way, performance wise, to partition on ENUM fields (e.g. KEY, LINEAR KEY, etc.)?

  • Answer:

    You only have one choice of partitioning type on an ENUM column:https://dev.mysql.com/doc/refman/5.6/en/partitioning-key.html. Make sure you choose exactly the same number of partitions as the number of elements in the enum. Otherwise you get some partitions for which multiple enum values map to it, while other partitions remain empty forever. Example: drop table if exists test.foo; create table test.foo ( id int auto_increment, e enum('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'), primary key(id, e) ); alter table test.foo drop key id; /* get rid of redundant UNIQUE key */ /* NOTE: 27 partitions for 26 enum elements */ alter table test.foo partition by key(e) partitions 27; insert into test.foo (e) values ('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h'), ('i'), ('j'), ('k'), ('l'), ('m'), ('n'), ('o'), ('p'), ('q'), ('r'), ('s'), ('t'), ('u'), ('v'), ('w'), ('x'), ('y'), ('z'); And you can see the results for yourself: select table_name, partition_name, table_rows from information_schema.partitions where table_name = 'foo'; table_name partition_name table_rows foo p0 2 foo p1 0 foo p2 1 foo p3 2 foo p4 0 foo p5 0 foo p6 2 foo p7 1 foo p8 0 foo p9 2 foo p10 2 foo p11 0 foo p12 0 foo p13 2 foo p14 0 foo p15 0 foo p16 2 foo p17 2 foo p18 0 foo p19 1 foo p20 2 foo p21 0 foo p22 0 foo p23 2 foo p24 1 foo p25 0 foo p26 2

Bill Karwin at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.