How does a php + mysql website reduce the number of database connections?
Source: Internet
Author: User
How does a php + mysql website reduce the number of database connections, you need to display the latest added items on the home page. The last updated items are the most searched items. The most recently searched items are the one sold in the category. the query for the specified item is for the same table. This table has many records and many fields. How can I reduce the number of times a database is linked to a php + mysql website for each query?
There is a website that needs to be displayed on the home page
Newly added item
Last Updated item
Most searched items
Recently searched item
The most sold items of the type
The most sold items of type B
Specified item
Specified item
The preceding query is for the same table. This table has many records and many fields. If each query is executed once. The cpu usage of the server is very high. A few people will be slow when accessing and refreshing at the same time.
Is there any caching technology available. I am not particularly familiar with php. Expected answers
------ Solution --------------------
Http://zhidao.baidu.com/question/73543180.html
I don't know if you are looking for this.
I did not actually write anything that I dare not say.
------ Solution --------------------
Does php Memcached help you? I have never used it myself. I am considering learning Memcached systematically.
------ Solution --------------------
The operation results are cached in memory or serialized and stored in files.
For example, the newly added item is written into the cache file home page during the insert into table operation to directly read the cache.
If you want to check whether updates are frequent or not, we recommend that you split the table.
------ Solution --------------------
The cache technology is the rescue of databases .. Memcache is a good choice for installation and use.
------ Solution --------------------
About cache technology (MemCached)
You can refer to the following two cases, certainly helpful to you: http://www.php100.com/html/shipinjiaocheng/PHP100shipinjiaocheng/2010/0125/3856.html
Http://www.php100.com/html/shipinjiaocheng/PHP100shipinjiaocheng/2010/0201/3897.html
------ Solution --------------------
Memcache is one aspect.
You can break down the table as needed. Do not always target a table, and the practice for a table is unreasonable. If you want to join a query, you can directly write the associated content to the target table.
Assume that the product table is goods.
Cart
Last Updated cart
Searchlog
Searchlog
Sold, the most sold sales table among the items of Type
Sold, the most sold sales table among the items of type B
Topads
Topads
-- I wrote a rough description above. When creating a cart table, you can create a field named goods_title to store the goods name.
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