All tables should have Primary Keys for Group replication in SQL #2129
Replies: 7 comments
-
I did a naive trial run on this problem after adding the fake_pk columns and reindexing we get the following error
I notice that |
Beta Was this translation helpful? Give feedback.
-
Looking into this further I've found that whilst MySQL tables do not necessarily need a primary key[1], if you are using group replication it is needed [2]. So Digital Ocean are right to keep warning... :( [1] https://dev.mysql.com/doc/refman/5.7/en/create-table.html#create-table-indexes-keys |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I wonder why EDIT: it's empty for me... so, I won't see any performance improvements. Not sure what it does since it is empty. |
Beta Was this translation helpful? Give feedback.
-
Sounds like a great addition, when doing this changes, please take the Branch |
Beta Was this translation helpful? Give feedback.
-
@Flyingmana assign it to me and I'll crack on with it... 👍 |
Beta Was this translation helpful? Give feedback.
-
I'm currently migrating a store to a cluster w/ PXC. Most tables IMHO do not need a new coloumn (maybe weee_discount does). Here is what I got: ALTER TABLE `api2_acl_user` DROP INDEX `UNQ_API2_ACL_USER_ADMIN_ID`, ADD PRIMARY KEY (`admin_id`) USING BTREE;
ALTER TABLE `api_session` DROP INDEX `IDX_API_SESSION_SESSID`, ADD PRIMARY KEY (`sessid`) USING BTREE;
ALTER TABLE `catalog_category_anc_categs_index_idx` DROP INDEX `IDX_CATALOG_CATEGORY_ANC_CATEGS_INDEX_IDX_CATEGORY_ID`, ADD PRIMARY KEY (`category_id`) USING BTREE;
ALTER TABLE `catalog_category_anc_categs_index_tmp` DROP INDEX `IDX_CATALOG_CATEGORY_ANC_CATEGS_INDEX_TMP_CATEGORY_ID`, ADD PRIMARY KEY (`category_id`) USING HASH;
ALTER TABLE `catalog_category_anc_products_index_idx` DROP INDEX `IDX_CAT_CTGR_ANC_PRDS_IDX_IDX_CTGR_ID_PRD_ID_POSITION`, ADD PRIMARY KEY (`category_id`, `product_id`, `position`) USING BTREE;
ALTER TABLE `catalog_category_anc_products_index_tmp` DROP INDEX `IDX_CAT_CTGR_ANC_PRDS_IDX_TMP_CTGR_ID_PRD_ID_POSITION`, ADD PRIMARY KEY (`category_id`, `product_id`, `position`) USING HASH;
ALTER TABLE `catalog_category_product_index_enbl_idx` ADD PRIMARY KEY(`product_id`);
ALTER TABLE `catalog_category_product_index_enbl_tmp` ADD PRIMARY KEY(`product_id`);
ALTER TABLE `catalog_category_product_index_idx` DROP INDEX `IDX_CAT_CTGR_PRD_IDX_IDX_PRD_ID_CTGR_ID_STORE_ID`, ADD PRIMARY KEY (`product_id`, `category_id`, `store_id`) USING BTREE;
ALTER TABLE `catalog_category_product_index_tmp` DROP INDEX `IDX_CAT_CTGR_PRD_IDX_TMP_PRD_ID_CTGR_ID_STORE_ID`, ADD PRIMARY KEY (`product_id`, `category_id`, `store_id`) USING HASH;
-- Already in setup 1.6. Was not applied for some reason
ALTER TABLE `log_url` DROP INDEX `url_id`, ADD PRIMARY KEY (`url_id`) USING BTREE;
ALTER TABLE `oauth_nonce` DROP INDEX `UNQ_OAUTH_NONCE_NONCE`, ADD PRIMARY KEY (`nonce`) USING BTREE;
-- Not sure about that - but we don't use it...
ALTER TABLE `weee_discount` ADD PRIMARY KEY (`entity_id`, `website_id`, `customer_group_id`);
ALTER TABLE `widget_instance_page_layout` DROP INDEX `UNQ_WIDGET_INSTANCE_PAGE_LAYOUT_LAYOUT_UPDATE_ID_PAGE_ID`, ADD PRIMARY KEY (`layout_update_id`, `page_id`) USING BTREE; |
Beta Was this translation helpful? Give feedback.
-
Summary (*)
When hosting OpenMage on Digital Ocean you get sent the following email daily (which is really annoying).
Examples (*)
The following tables don't have primary keys:
api2_acl_user
api_session
catalog_category_anc_categs_index_idx
catalog_category_anc_categs_index_tmp
catalog_category_anc_products_index_idx
catalog_category_anc_products_index_tmp
catalog_category_product_index_enbl_idx
catalog_category_product_index_enbl_tmp
catalog_category_product_index_idx
catalog_category_product_index_tmp
log_url
m_db
oauth_nonce
weee_discount
widget_instance_page_layout
Proposed solution
1.) Identify unique combinations of columns and create PKs on them
2.) Where uniqueness cannot be guaranteed create an update script that adds new PK column.
3.) Test and alter all CRUD operations to be aware of the new PK especially if they are new columns rather than keys simply added to existing columns.
Beta Was this translation helpful? Give feedback.
All reactions