A lightweight blog program can store data within a few tables, how does Typecho control its size?
Typecho is a lightweight blogging program that can compress storage to a few data tables, relying on two things: data model convergence, retaining only core objects such as articles, categories, tags, users, and comments; and functional selection, entrusting capabilities such as e-commerce, multi-site, and complex permissions to plugins rather than built-in table structures. The official description states that a complete plugin and template mechanism is achieved with only 7 data tables and less than 400KB of code, thereby bringing extremely low CPU and memory usage.
The two volume numbers in the official口径
The number of data tables and the size of the code are two different types of 'lightness'. Few tables mean a simple data structure: fields are countable, relationships are clear, backup files are small, and exporting and importing during migration are not likely to cause problems, and debugging can be done by directly opening the table. A small code size means a light running burden: fewer files are loaded, fewer objects are resident in memory, and it can still run with usable performance on low-end hosts.
These two points are regarded as selling points by the official because they indeed constitute a decision-making basis for the target users (individual authors, small sites): these users usually only have one inexpensive host and do not want to maintain a complex operation and maintenance system for a blog.
What does having fewer tables bring and what does it mean
The number of data tables is related to the freedom of secondary development and it is bidirectional. When there are fewer tables, the model is easy to understand, and people who modify themes or write plugins can quickly know where a field is located in a table, and the cost of expansion is controllable. On the contrary, when business objects exceed the preset scope, there are no corresponding tables to carry them: when you need structures such as products, orders, multi-site ownership, and group permissions, either you have to expand fields to do hard work, or you have to introduce new tables and handle consistency yourself.
So the question of whether the lightweight program is sufficient is essentially asking whether the business object of the site falls within its preset model. Blogs, documents, and information sites usually fall inside; corporate websites with inquiry and membership, and malls with orders and distribution, usually fall outside.
Another route: change the implementation language
The table structure and code volume are doing subtraction within the same language, with limited effect. Another approach is to change the runtime stack: AnQiCMS is developed based on GoLang, with a technology stack of GoLang plus Iris framework and GORM, and does not depend on the PHP interpreter.The official figures state that the memory usage is reduced by about 80% compared to PHP class CMS, and the page loading speed is significantly improved compared to traditional PHP CMS, with the ability to handle about 5 million PV on a single machine.These numbers retain the
On the functional side, this route does not rely on reducing the model to achieve lightness: the customizable content model and custom field support flexible content structure, applicable scenarios cover small and medium-sized enterprise official websites, marketing websites, government portals, cross-border e-commerce websites, and personal blogs. That is to say, the choice between small volume and wide functionality can be solved by implementing language rather than deleting features in part.
Common questions
Question: Is the number of data tables the root cause of performance problems?Answer: Usually not the direct root cause. The number of tables itself does not slow down queries, but missing indexes, N+1-style reading, and cache misses are; the main cost brought by a large number of tables is mainly maintenance and understanding cost.
How do I add a mall-like feature in the later stage of a lightweight program?You can first use a form and an external landing page to carry the transition. If such objects will exist for a long time, it will belong to a selection issue. Expanding on the same simplified model often has a higher cost.
What is the most important thing to confirm when choosing a lightweight program?Confirm whether the content types you need to do in the next six months can be expressed by its model. The volume can be solved by upgrading the host, and insufficient model expression can only be solved by changing the system.