简体   繁体   English

mysql db结构以获得更好的性能

[英]mysql db structure for better performance

I'm not a professional, but I'm messing around with wordpress trying to customize it the way I want it to work... 我不是专业人士,但是我想尝试以我希望它的工作方式对其进行自定义...

I've a necessity to add additional data to single-posts, specifically a restaurant menu, each post will have unique menu displayed in sidebar. 我有必要向单个帖子中添加其他数据,特别是在餐厅菜单中,每个帖子的边栏中都将显示唯一的菜单。

Single post is a single row in wp_posts table. 单个帖子是wp_posts表中的一行。

wp_posts

I'm adding additional info using wp metabox functionality, which has its own table called wp_postmeta. 我正在使用wp metabox功能添加其他信息,该功能具有自己的名为wp_postmeta的表。

This table is different from wp_posts because it can contain many rows of meta information for a single post. 该表与wp_posts不同,因为它可以包含单个帖子的许多元信息行。

wp_postmeta

My questions: 我的问题:

Is this implementation slow? 这个执行速度慢吗? Will it cause problems if db grows? 如果db增长会引起问题吗? Why would wp guyz implement this in this way? 为什么wp guyz这样实现? Would not it be wiser to have single meta column and multiple rows per post? 每个帖子只有一个元列和多个行会更明智吗?

I see that you have "price_list_heading", "price_list_category","price_list_heading1", "price_list_category1","price_list_heading2", "price_list_category2","price_list_heading3" and "price_list_category3" I don't know why, but I think you shouldn't do that, you need to create a relational table with index (I don't know if Wordpress let you do that) 我看到您有“ price_list_heading”, "price_list_category","price_list_heading1", "price_list_category1","price_list_heading2", "price_list_category2","price_list_heading3" and "price_list_category3"我不知道为什么,但是我认为为此,您需要创建一个带有索引的关系表(我不知道Wordpress是否允许您这样做)

it'd will look like: this will depend of the cardinality of your APP 它看起来像:这将取决于您的APP的基数

Let's say that 1 post meta can have multiple categories and multiple categories can be with one postmeta (cardinality N:M) 假设1个后置元可以具有多个类别,并且多个类别可以包含一个后置元(基数N:M)

在此处输入图片说明

Now If one post can have multiple categories and one category can have only one post 现在,如果一个帖子可以有多个类别,而一个类别只能有一个帖子

在此处输入图片说明

Where wp_postmeta_copy1 is a FK from ws_postmeta table (id) 其中wp_postmeta_copy1是ws_postmeta表(id)中的FK

Please take a look to this documentation : 请查看以下文档:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM