简体   繁体   English

需要有关优化的帮助

[英]Need Help regarding Optimization

First of all I am an autodidact so I don't have great know how about optimization and stuff. 首先,我是一个自动整理者,所以我对优化和内容知之甚少。 I created a social networking website. 我创建了一个社交网站。

It contains 29 tables right now. 它现在包含29个表。 I want to extend its functionality by adding things like yellow pages, events etc to make it more like a portal. 我想通过添加黄页,事件等内容来扩展其功能,使其更像门户。

Now the question is should I simply add the tables in the same database or should I use a different database? 现在的问题是,我应该只是将表添加到同一数据库中还是应该使用其他数据库?

And in case if I create a new database, I also want users to be able to comment on business listing etc just like reviews. 而且,如果我创建一个新的数据库,我也希望用户能够像评论一样对公司列表等发表评论。 So how will I be able to pull out entries since the reviews will be on one database and user details on other. 因此,由于评论将在一个数据库上,而用户详细信息将在另一个数据库上,因此我将如何能够提取条目。

Is it possible to join tables on 2 different databases ? 是否可以在2个不同的数据库上联接表?

Don't Optimize until you need to. 在需要之前不要进行优化。

If performance is ok, go for the easiest to maintain solution. 如果性能还可以,请寻求最容易维护的解决方案。

Monitor the performance of your site and if it starts to get slow, figure out exactly what is causing the slowdown and focus on performance on that section only. 监视网站的性能,如果它开始变慢,请准确找出导致速度变慢的原因,然后仅关注该部分的性能。

You can join tables in separate databases by fully justifying the name, but the real question is why do you want the information in separate databases? 您可以通过完全证明名称的名称来连接独立数据库中的表,但真正的问题是为什么要在独立数据库中获取信息? If the information you are storing all relates together, it should go in one database unless there is a compelling (usually performance related) reason against it. 如果您存储的所有信息都关联在一起,则应该将其放入一个数据库中,除非有令人信服(通常与性能相关)的理由。

The main reason I could see for separating your YellowPages out is if you wished to have one YellowPages accessible to several different, non-interacting, websites. 我看到将YellowPages分开的主要原因是,如果您希望让一个YellowPages可以访问多个不同的,非交互的网站。 That said, assumably you wouldn't want cross-talk comments on the listings, so comments would need to be stored in the website databases rather than the YellowPages database. 就是说,假设您不想在清单上出现串扰评论,因此评论需要存储在网站数据库中,而不是YellowPages数据库中。 And that just sounds like a maintenance nightmare. 这听起来像是一场维护噩梦。

You definitely can query and join tables from two different databases - you just need to specify the tables in a dbname.tablename format. 您绝对可以查询和连接来自两个不同数据库的表-您只需要以dbname.tablename格式指定表dbname.tablename

SELECT a.username, b.post_title
FROM dbOne.users a INNER JOIN dbTwo.posts b USING (user_id)

However, it might make management and maintenance a lot more complicated for you. 但是,这可能会使您的管理和维护变得更加复杂。 For example, you'll have to track which table belongs in which database, and will continually need to be adding the database names into all your queries. 例如,您必须跟踪哪个表属于哪个数据库,并且将不断需要将数据库名称添加到所有查询中。 When it comes time to back up the data, your work will increase there as well. 当需要备份数据时,您的工作也将在那里增加。 MySQL databases can easily contain hundreds of tables so I see no benefit in splitting it up - just stick with one. MySQL数据库可以轻松地包含数百个表,因此我看不到拆分它的好处-坚持使用一个表。

You can prove an algorithm is the fastest it can. 您可以证明算法是最快的。 math.h and C libraries are very optimized since half a century and other very advances when optimizing is perl strucutres. 自半个世纪以来,math.h和C库都进行了非常优化,并且在优化Perl结构时还取得了其他进步。 Just avoid put everything on online to easify debugging. 只是要避免一切都在线以简化调试。 There're conventions, try keep every programmer in the team following same convention. 有约定,请尝试使团队中的每个程序员都遵循相同的约定。 Which convention is "right" makes less optimum than being consequent and consistent. 哪种约定是“正确的”,并没有随之而来的和一致的最优性。 Performance is the last thing you do, security and intelligibility top prios. 性能是您要做的最后一件事,安全性和清晰度是当务之急。 Read about ordo notation depends on software only while suboptimal software can be faster than optimal relative different hardware. 了解ordo表示法仅取决于软件,而次优的软件可能比最佳的相对不同的硬件要快。 A totally buginfested spaghetti code with no structure can respond many times faster than the most proven optimal software relative hardware. 没有结构的完全错误的意大利面条代码的响应速度比最可靠的最佳软件相关硬件快许多倍。

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

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