Tuesday, January 25, 2022

What is a website database.

What is a website database?

What is it for, how to manage it, and what does the site load speed have to do with it? And there are so-called revisions that add their own features when working. Let's look at all this from the outside, so that you can then skillfully handle the database of your site. At the same time, we will find out how long it takes for the request to go to the base and bring the information found back to the site.
Brief introductory paragraph
Any information on the site needs to be stored somewhere. This is an obvious fact. But the storage locations may be different. The first option is right inside the HTML or PHP file. This method is common. This is when you open a page in the admin panel to edit the information there, and inside the page is empty. At all. But when viewing a page on the site, there is text, pictures, and other data.
As an IT volunteer, I probably had about a dozen tasks when it was necessary to change information in this way. The thing is that in this case, the text and links to images are added directly to the PHP file of the site's theme. To change the page, you need to go to the hosting in the theme folder and edit the desired file.
The second option for storing data is more convenient and familiar. This is when you open a page in the admin panel, see all the data there and calmly change them. Refresh the page and you're done. With this scheme, the data is updated dynamically and is already taken from the database. Here we'll talk about her.

What is a database

Technically, this is a .sql file (for a WordPress site). Inside it has tables that have rows. And the data is already written in the lines. It is from here that this data is taken for display on the pages of the site. The main advantage of such a data storage scheme is that all information is in one file. This means it can be easily saved.
In addition to page information, the database contains a lot of service information. All in all, an important file. You can view the list of databases in your hosting account in the "Databases" section.

List of databases hosted by Timeweb


This is a list of bases. You can go inside each and see what is being done there using the full access link - circled in red in the screenshot above. phpMyAdmin is, in turn, a web application for managing databases. And the information inside it will be a little more unusual. Therefore, you can go there and look, but change anything there - only knowing exactly what you are doing. Well, or having a backup copy of the database in stock.
And here is the site loading speed
The connection here is the most direct. The smaller the database, the faster it will find information for further display on the site. And vice versa. In addition, in addition to the content of the pages, other service information is stored in the database.
And this is, first of all, the data of all plugins of the site. If you have a security plugin that records all user activity (failed login attempts, active sessions), then where does it store all this data? It's all there, in the database. Only in a separate table.
The database stores all comments on the site, data of all registered users, all links, and site settings. In short, everything. Without a database, your site simply will not open. Instead, a blank screen is displayed with the phrase "Error establishing a connection to the database." Therefore, the more content and plugins on the site, the larger the size of the database. This means that over time, the speed of the site may drop.

What are post and page revisions

In English, this is called revision. In this context, it can be translated into Russian as a copy (or edition) of the page. Every time you change a page on your site and save it, WordPress creates a copy of the page with your changes. If after 5 minutes you remember that you forgot to put a comma in the text and change and save the page again, another copy will be created.
On the one hand, this scheme is good. After all, you can, if necessary, roll back to the previous edition of the page. But, on the other hand, a lot of such copies can be created. And all of them are stored, as you understand, all in the same database. And all this is not the best way to affect the performance of the site.
Therefore, such copies need to be deleted from time to time. This can be done using the Optimize Database after Deleting Revisions plugin.
Screenshot of plugin page in WordPress directory

In addition to removing revisions, the plugin is good because it shows the size of each table in the database and its total size. And if, after analyzing the database, you see that there are too many rows in a table, then you need to look carefully at what is stored in this table and how it can be optimized.
I have the following plugin settings:
Screenshot of database optimization plugin settings

The first two checkboxes are responsible for deleting revisions from posts and pages. The plugin does its job, and nothing more is needed from it. This optimization often frees up a lot of space and makes the database lighter.
Speaking of plugins, the Teplitsa website has an article about plugins for various tasks for a WordPress site. Look, read.
In general, think of a database as a filing cabinet. Each box is filled with information on its section. If there is not enough space in the box, then you need to either clean it up or start a new box nearby. A lot of data - a lot of boxes. There is such a system in libraries where book cards are stored - on which shelf which book is located. This is the most illustrative example of how a database works.

What is the result

Yes, this entire database is a little more complicated than editing pages in the site's admin panel. But you can still figure it out. I highly recommend at least checking the size of your site's database. You can do this on hosting or through a plugin, whichever is more convenient for you. If you see a lot of rows in some tables there, it means that there is a reason to understand the reasons and clean up there. Do it yourself or create a task on an it-volunteer. I do not remember such tasks there, it will be interesting.


TOP-5 database management systems

  TOP-5 database management systems A database management system (abbreviated as DBMS) is software for creating and working with databases. ...