Several common database design problems such as reply number, list paging and so on

Source: Internet
Author: User
Help: Several common database design problems such as reply number, list paging, etc.
I built a blog, the brief needs are as follows: In the article (article) list page to display the number of comments, the list of articles to be paginated display, the list of comments (Comment) will be paginated (the comments list is displayed by Ajax pagination).

Because I haven't done many projects, I want to ask a few questions:

1. Does the number of comments like comment generally be a field of the article table or is it implemented by select count? If it is implemented by select count then each time the N article is displayed in the list of articles, then executing n select count to query the number of replies will degrade performance?

2. Let's say that there are many articles in the blog home page (such as: Weekly ranking, daily ranking, recent hits, related articles, latest articles, latest comments, etc.), in addition to some of the list blocks (such as the weekly ranking, the number of these less updated parts) to do the cache, Does an HTTP request execute with 10 SELECT statements (all of the SELECT statements have been optimized) not too much?
------Optimal Solution--------------------
1, should be stored with a field
2, in principle, to minimize the search. But if your blog does not have a large number of visits, it is nothing.
------Other Solutions--------------------
It should be stored in 1 fields, but it is best to do an initialization program to re-count it, otherwise it may be a long time error.

If you do not want to use Word Gencun, you can use the cache
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.