2关于更好优化数据库设计的问题
1)在mysql引擎中,MyISAM更好还是InnoDB更好?
2)我想编写一个CMS,它可以添加带有多类别的帖子 我必须如何设计数据库才能通过一些查询获得更好的性能?
在 php 中如何列出帖子的类别例如 = 1 ?
谢谢
1) In mysql engines, MyISAM Is Better Or InnoDB ?
2) i want programming a cms that it could add a post with multi category
how i must design my database to have a better performance with a few query ?
in php how can list posts which category for example = 1 ?
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1) 如果您需要数据库级别的外键关系,请使用 InnoDB,否则使用 MyISAM
2) 您可以将所有类别存储在一个表中,其架构类似于
具有 Category_ID 主键的
架构3)
编辑:post 表的架构(示例)
Post_ID< /code> 是
posts
表的主键。请注意,如果您的帖子属于类别 1,2 和 3,则 Category_ID 现在是
varchar
存储类别的值,如1,2,3
..以及删除所有帖子属于类别 1,您将运行以下查询1) If you need foreign keys relations on DB level use InnoDB else use MyISAM
2) You can store all categories in one table with schema like that
with Category_ID primary key
3)
edit : Schema of post table (example)
Post_ID
is primary key ofposts
table.note the Category_IDs is now
varchar
store value of categories in it like1,2,3
if your post belongs to cateory 1,2 and 3.. and for deleting all posts belonging to category 1 you will run following query没有明确的答案,因为这取决于您的需求,但是,很多人已经提到过以下内容:
然而,没有多少人会提到 innodb 聚集主键索引,以及一张设计良好的 innodb 表如何轻松地胜过同等的 myisam 索引。
以下是解释聚集索引的两个链接:
http:// dev.mysql.com/doc/refman/5.0/en/innodb-index-types.html
http://www.xaprb.com/blog/2006/07/04/how-to-exploit-mysql-index-optimizations/
此外,请查看以下示例和文章(第二个示例可能具有特别相关性)
5 亿行论坛/话题示例
MySQL 和 NoSQL :帮我选择一个合适的
1.25 亿行产品/类别示例
重写mysql select减少时间并将 tmp 写入磁盘
1亿行实验
最佳 MySQL 设置用于提供大量数据的查询?
Innodb、myisam 与 falcon 基准测试
http: //www.mysqlperformanceblog.com/2007/01/08/innodb-vs-myisam-vs-falcon-benchmarks-part-1/
希望这有帮助:)
There is no definitive answer as it depends on your requirements but, lots of people will have already mentioned things such as:
However not many people will mention innodb clustered primary key indexes and how a well designed innodb table will easily out perform an equivalent myisam one because of this.
Here are two links explaining clustered indexes:
http://dev.mysql.com/doc/refman/5.0/en/innodb-index-types.html
http://www.xaprb.com/blog/2006/07/04/how-to-exploit-mysql-index-optimizations/
Also, have a look at the following examples and articles (second example may have particular relevance)
500 million row forum/thread example
MySQL and NoSQL: Help me to choose the right one
125 million row product/category example
Rewriting mysql select to reduce time and writing tmp to disk
100 million row experiment
Optimal MySQL settings for queries that deliver large amounts of data?
Innodb vs. myisam vs. falcon benchmarks
http://www.mysqlperformanceblog.com/2007/01/08/innodb-vs-myisam-vs-falcon-benchmarks-part-1/
Hope this helps :)