2017-06-15 13 views
1

以下のパーティション構成を作成しようとしていますが、エラーが表示されています。パーティションのエラーMySql 5.5

MySQLデータベースエラー:SQL構文にエラーがあります。近くに使用する権利構文についてはMySQLサーバのバージョンに対応するマニュアルをチェック '(my_dateを)、月(my_date))( p0パーティションのVALUES LESS THAN(2010、1)、 パーティションP1' 行2

で。?

これは、あなたがこのテーブルを分割する必要がある場合、あなたはおそらくこのような何かを試してみたい

私のテーブルには、あなたが範囲とリスト・パーティションを混合している10K

ALTER TABLE my_table 
PARTITION by LIST COLUMNS (year(my_date), month(my_date))(
    PARTITION p0 VALUES LESS THAN (2010, 1), 
PARTITION p1 VALUES LESS THAN (2010, 2), 
PARTITION p2 VALUES LESS THAN (2010, 3), 
PARTITION p3 VALUES LESS THAN (2010, 4), 
PARTITION p4 VALUES LESS THAN (2010, 5), 
PARTITION p5 VALUES LESS THAN (2010, 6), 
PARTITION p6 VALUES LESS THAN (2010, 7), 
PARTITION p7 VALUES LESS THAN (2010, 8), 
PARTITION p8 VALUES LESS THAN (2010, 9), 
PARTITION p9 VALUES LESS THAN (2010, 10), 
PARTITION p10 VALUES LESS THAN (2010, 11), 
PARTITION p11 VALUES LESS THAN (2010, 12), 
PARTITION p12 VALUES LESS THAN (2011, 1), 
PARTITION p13 VALUES LESS THAN (2011, 2), 
PARTITION p14 VALUES LESS THAN (2011, 3), 
PARTITION p15 VALUES LESS THAN (2011, 4), 
PARTITION p16 VALUES LESS THAN (2011, 5), 
PARTITION p17 VALUES LESS THAN (2011, 6), 
PARTITION p18 VALUES LESS THAN (2011, 7), 
PARTITION p19 VALUES LESS THAN (2011, 8), 
PARTITION p20 VALUES LESS THAN (2011, 9), 
PARTITION p21 VALUES LESS THAN (2011, 10), 
PARTITION p22 VALUES LESS THAN (2011, 11), 
PARTITION p23 VALUES LESS THAN (2011, 12), 
PARTITION p24 VALUES LESS THAN (2013, 1), 
PARTITION p25 VALUES LESS THAN (2013, 2), 
PARTITION p26 VALUES LESS THAN (2013, 3), 
PARTITION p27 VALUES LESS THAN (2013, 4), 
PARTITION p28 VALUES LESS THAN (2013, 5), 
PARTITION p29 VALUES LESS THAN (2013, 6), 
PARTITION p30 VALUES LESS THAN (2013, 7), 
PARTITION p31 VALUES LESS THAN (2013, 8), 
PARTITION p32 VALUES LESS THAN (2013, 9), 
PARTITION p33 VALUES LESS THAN (2013, 10), 
PARTITION p34 VALUES LESS THAN (2013, 11), 
PARTITION p35 VALUES LESS THAN (2013, 12), 
PARTITION p36 VALUES LESS THAN (2014, 1), 
PARTITION p37 VALUES LESS THAN (2014, 2), 
PARTITION p38 VALUES LESS THAN (2014, 3), 
PARTITION p39 VALUES LESS THAN (2014, 4), 
PARTITION p40 VALUES LESS THAN (2014, 5), 
PARTITION p41 VALUES LESS THAN (2014, 6), 
PARTITION p42 VALUES LESS THAN (2014, 7), 
PARTITION p43 VALUES LESS THAN (2014, 8), 
PARTITION p44 VALUES LESS THAN (2014, 9), 
PARTITION p45 VALUES LESS THAN (2014, 10), 
PARTITION p46 VALUES LESS THAN (2014, 11), 
PARTITION p47 VALUES LESS THAN (2014, 12), 
PARTITION p48 VALUES LESS THAN (2015, 1), 
PARTITION p49 VALUES LESS THAN (2015, 2), 
PARTITION p50 VALUES LESS THAN (2015, 3), 
PARTITION p51 VALUES LESS THAN (2015, 4), 
PARTITION p52 VALUES LESS THAN (2015, 5), 
PARTITION p53 VALUES LESS THAN (2015, 6), 
PARTITION p54 VALUES LESS THAN (2015, 7), 
PARTITION p55 VALUES LESS THAN (2015, 8), 
PARTITION p56 VALUES LESS THAN (2015, 9), 
PARTITION p57 VALUES LESS THAN (2015, 10), 
PARTITION p58 VALUES LESS THAN (2015, 11), 
PARTITION p59 VALUES LESS THAN (2015, 12), 
PARTITION p60 VALUES LESS THAN (2016, 1), 
PARTITION p61 VALUES LESS THAN (2016, 2), 
PARTITION p62 VALUES LESS THAN (2016, 3), 
PARTITION p63 VALUES LESS THAN (2016, 4), 
PARTITION p64 VALUES LESS THAN (2016, 5), 
PARTITION p65 VALUES LESS THAN (2016, 6), 
PARTITION p66 VALUES LESS THAN (2016, 7), 
PARTITION p67 VALUES LESS THAN (2016, 8), 
PARTITION p68 VALUES LESS THAN (2016, 9), 
PARTITION p69 VALUES LESS THAN (2016, 10), 
PARTITION p70 VALUES LESS THAN (2016, 11), 
PARTITION p71 VALUES LESS THAN (2016, 12), 
PARTITION p72 VALUES LESS THAN (2017, 1), 
PARTITION p73 VALUES LESS THAN (2017, 2), 
PARTITION p74 VALUES LESS THAN (2017, 3), 
PARTITION p75 VALUES LESS THAN (2017, 4), 
PARTITION p76 VALUES LESS THAN (2017, 5), 
PARTITION p77 VALUES LESS THAN (2017, 6), 
PARTITION p78 VALUES LESS THAN (2017, 7), 
PARTITION p79 VALUES LESS THAN (2017, 8), 
PARTITION p80 VALUES LESS THAN (2017, 9), 
PARTITION p81 VALUES LESS THAN (2017, 10), 
PARTITION p82 VALUES LESS THAN (2017, 11), 
PARTITION p83 VALUES LESS THAN (2017, 12), 
PARTITION p84 VALUES LESS THAN (2018, 1), 
PARTITION p85 VALUES LESS THAN (2018, 2), 
PARTITION p86 VALUES LESS THAN (2018, 3), 
PARTITION p87 VALUES LESS THAN (2018, 4), 
PARTITION p88 VALUES LESS THAN (2018, 5), 
PARTITION p89 VALUES LESS THAN (2018, 6), 
PARTITION p90 VALUES LESS THAN (2018, 7), 
PARTITION p91 VALUES LESS THAN (2018, 8), 
PARTITION p92 VALUES LESS THAN (2018, 9), 
PARTITION p93 VALUES LESS THAN (2018, 10), 
PARTITION p94 VALUES LESS THAN (2018, 11), 
PARTITION p95 VALUES LESS THAN (2018, 12), 
PARTITION p96 VALUES LESS THAN (2019, 1), 
PARTITION p97 VALUES LESS THAN (2019, 2), 
PARTITION p98 VALUES LESS THAN (2019, 3), 
PARTITION p99 VALUES LESS THAN (2019, 4), 
PARTITION p100 VALUES LESS THAN (2019, 5), 
PARTITION p101 VALUES LESS THAN (2019, 6), 
PARTITION p102 VALUES LESS THAN (2019, 7), 
PARTITION p103 VALUES LESS THAN (2019, 8), 
PARTITION p104 VALUES LESS THAN (2019, 9), 
PARTITION p105 VALUES LESS THAN (2019, 10), 
PARTITION p106 VALUES LESS THAN (2019, 11), 
PARTITION p107 VALUES LESS THAN (2019, 12), 
PARTITION p108 VALUES LESS THAN (2020, 1), 
PARTITION p109 VALUES LESS THAN (2020, 2), 
PARTITION p110 VALUES LESS THAN (2020, 3), 
PARTITION p111 VALUES LESS THAN (2020, 4), 
PARTITION p112 VALUES LESS THAN (2020, 5), 
PARTITION p113 VALUES LESS THAN (2020, 6), 
PARTITION p114 VALUES LESS THAN (2020, 7), 
PARTITION p115 VALUES LESS THAN (2020, 8), 
PARTITION p116 VALUES LESS THAN (2020, 9), 
PARTITION p117 VALUES LESS THAN (2020, 10), 
PARTITION p118 VALUES LESS THAN (2020, 11), 
PARTITION p119 VALUES LESS THAN (2020, 12), 
PARTITION p120 VALUES LESS THAN (2021, 1), 
PARTITION p121 VALUES LESS THAN (2021, 2), 
PARTITION p122 VALUES LESS THAN (2021, 3), 
PARTITION p123 VALUES LESS THAN (2021, 4), 
PARTITION p124 VALUES LESS THAN (2021, 5), 
PARTITION p125 VALUES LESS THAN (2021, 6), 
PARTITION p126 VALUES LESS THAN (2021, 7), 
PARTITION p127 VALUES LESS THAN (2021, 8), 
PARTITION p128 VALUES LESS THAN (2021, 9), 
PARTITION p129 VALUES LESS THAN (2021, 10), 
PARTITION p130 VALUES LESS THAN (2021, 11), 
PARTITION p131 VALUES LESS THAN (2021, 12), 
PARTITION p132 VALUES LESS THAN (2022, 1), 
PARTITION p133 VALUES LESS THAN (2022, 2), 
PARTITION p134 VALUES LESS THAN (2022, 3), 
PARTITION p135 VALUES LESS THAN (2022, 4), 
PARTITION p136 VALUES LESS THAN (2022, 5), 
PARTITION p137 VALUES LESS THAN (2022, 6), 
PARTITION p138 VALUES LESS THAN (2022, 7), 
PARTITION p139 VALUES LESS THAN (2022, 8), 
PARTITION p140 VALUES LESS THAN (2022, 9), 
PARTITION p141 VALUES LESS THAN (2022, 10), 
PARTITION p142 VALUES LESS THAN (2022, 11), 
PARTITION p143 VALUES LESS THAN (2022, 12), 
PARTITION p144 VALUES LESS THAN (2023, 1), 
PARTITION p145 VALUES LESS THAN (2023, 2), 
PARTITION p146 VALUES LESS THAN (2023, 3), 
PARTITION p147 VALUES LESS THAN (2023, 4), 
PARTITION p148 VALUES LESS THAN (2023, 5), 
PARTITION p149 VALUES LESS THAN (2023, 6), 
PARTITION p150 VALUES LESS THAN (2023, 7), 
PARTITION p151 VALUES LESS THAN (2023, 8), 
PARTITION p152 VALUES LESS THAN (2023, 9), 
PARTITION p153 VALUES LESS THAN (2023, 10), 
PARTITION p154 VALUES LESS THAN (2023, 11), 
PARTITION p155 VALUES LESS THAN (2023, 12), 
PARTITION p156 VALUES LESS THAN (2024, 1), 
PARTITION p157 VALUES LESS THAN (2024, 2), 
PARTITION p158 VALUES LESS THAN (2024, 3), 
PARTITION p159 VALUES LESS THAN (2024, 4), 
PARTITION p160 VALUES LESS THAN (2024, 5), 
PARTITION p161 VALUES LESS THAN (2024, 6), 
PARTITION p162 VALUES LESS THAN (2024, 7), 
PARTITION p163 VALUES LESS THAN (2024, 8), 
PARTITION p164 VALUES LESS THAN (2024, 9), 
PARTITION p165 VALUES LESS THAN (2024, 10), 
PARTITION p166 VALUES LESS THAN (2024, 11), 
PARTITION p167 VALUES LESS THAN (2024, 12), 
PARTITION p168 VALUES LESS THAN (2025, 1), 
PARTITION p169 VALUES LESS THAN (2025, 2), 
PARTITION p170 VALUES LESS THAN (2025, 3), 
PARTITION p171 VALUES LESS THAN (2025, 4), 
PARTITION p172 VALUES LESS THAN (2025, 5), 
PARTITION p173 VALUES LESS THAN (2025, 6), 
PARTITION p174 VALUES LESS THAN (2025, 7), 
PARTITION p175 VALUES LESS THAN (2025, 8), 
PARTITION p176 VALUES LESS THAN (2025, 9), 
PARTITION p177 VALUES LESS THAN (2025, 10), 
PARTITION p178 VALUES LESS THAN (2025, 11), 
PARTITION p179 VALUES LESS THAN (2025, 12), 
PARTITION p180 VALUES LESS THAN (MAXVALUE, MAXVALUE)  
); 

答えて

0

ある 最善の方法ですusing the EXTRACT() function

PARTITION by RANGE (EXTRACT(YEAR_MONTH FROM my_date)) 
    PARTITION p0 VALUES LESS THAN (201001), 
    PARTITION p1 VALUES LESS THAN (201002), 
    PARTITION p2 VALUES LESS THAN (201003), 
    ... 

しかし、それは終わったと思う。パーティショニングを導入するには、スタッフとパフォーマンスの両方のコストが必要です。

  • スタッフ費用:システムを稼動させているときに、しばしばパーティションを追加する必要があります。
  • パフォーマンスコスト:クエリが複数のパーティションを見る必要があり、IOサイクルを要するため、クエリが馬鹿げてゆっくり実行されることがあります。そのようなパフォーマンスの問題はあなたに戻ってきます....
  • スタッフ費用:あなたのアプリケーションを遅らせるために何が起こったのか把握する必要があります。

首に痛みがあります。

パーティション化は、一般に、テーブルサイズが大きくなる、つまり少なくとも数千万行になる場合に最も便利です。約10K行のあなたのテーブルは、(尊重されて)小さなテーブルと見なされます。 MySQLと他のRDMSシステムは何百万行ものテーブルを問題なく扱うことができます。

パーティション分割の仕組みを理解する上で害はありません。しかし、あなたのテーブルは生産に役立つには小さすぎます。

+0

OPS申し訳ありません10 MBの行10,000,000 - >サイトへの各アクセスを登録するため、非常に高速になります。 – kurole

+0

検索エラー - MySQLデータベースエラー:PRIMARY KEYには、テーブルのパーティション機能 – kurole

関連する問題