partitionierte_tabellen_mit_mysql
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| partitionierte_tabellen_mit_mysql [2022-04-25 13:32:32] – [PARTITION BY RANGE] manfred | partitionierte_tabellen_mit_mysql [2024-03-28 14:07:29] (aktuell) – [PARTITION BY HASH] manfred | ||
|---|---|---|---|
| Zeile 57: | Zeile 57: | ||
| ) | ) | ||
| ; | ; | ||
| + | |||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | |||
| + | SICHERE_TAGE=" | ||
| + | |||
| + | DATENBANK=" | ||
| + | TABELLE=" | ||
| + | MYSQL=" | ||
| + | |||
| + | |||
| + | # für jeden Tag eine Partition anlegen | ||
| + | echo " | ||
| + | ALTER TABLE ${DATENBANK}.${TABELLE} | ||
| + | PARTITION BY RANGE (UNIX_TIMESTAMP(datetime)) ( | ||
| + | $(for i in $(seq -7 ${SICHERE_TAGE}) | ||
| + | do | ||
| + | echo " | ||
| + | done | tac) | ||
| + | PARTITION p0 VALUES LESS THAN MAXVALUE | ||
| + | ) | ||
| + | ; | ||
| + | " | ${MYSQL} | ||
| + | </ | ||
| ==== PARTITION BY HASH ==== | ==== PARTITION BY HASH ==== | ||
| + | |||
| + | * [[https:// | ||
| Um eine Tabelle nach HASH zu partitionieren, | Um eine Tabelle nach HASH zu partitionieren, | ||
| + | |||
| + | // | ||
| Man sollte die Anzahl der Partitionen als einen Wert von '' | Man sollte die Anzahl der Partitionen als einen Wert von '' | ||
| - | | + | <file SQL Tabelle_partitionieren_-_HASH.sql> |
| - | PARTITION BY HASH (id) | + | ALTER TABLE `promotion_tracking_backend`.`CrossSiteTrackingData` |
| - | PARTITIONS 16; | + | PARTITION BY HASH (id) |
| + | PARTITIONS 16; | ||
| + | </ | ||
| + | |||
| + | SELECT TABLE_SCHEMA, | ||
| + | |||
| + | |||
| + | ==== PARTITION BY LINEAR HASH ==== | ||
| + | |||
| + | * [[https:// | ||
| + | |||
| + | **LINEAR HASH Partitioning: | ||
| + | MySQL unterstützt auch lineares Hashing, das sich von regulärem Hashing darin unterscheidet, | ||
| - | SELECT PARTITION_NAME, | + | //'' |
| + | <code sql> | ||
| + | ALTER TABLE `promotion_tracking_backend`.`CrossSiteTrackingData` | ||
| + | PARTITION BY LINEAR HASH (id) | ||
| + | PARTITIONS 16; | ||
| + | </ | ||
| ===== partitionierte Tabelle neu anlegen ===== | ===== partitionierte Tabelle neu anlegen ===== | ||
/home/http/wiki/data/attic/partitionierte_tabellen_mit_mysql.1650893552.txt · Zuletzt geändert: von manfred
