Any 1C:Enterprise infobase requires periodic execution of a specific set of scheduled operations.
For example, when you modify existing data or add new data, you need to create backups. If your infobase gets out of order due to a failure, you can restore the majority of data from a backup copy. So the more frequently you use backups, the less data you need to reenter if a failure occurs.
Another example: in order to be able to use full-text search in a database, you need to index the data. This means that the full-text index should be regularly updated. How frequently? It depends on the intensity of data additions and modifications. But it is obvious that some specific interval should be used.
To automate such operations, 1C:Enterprise offers the scheduled jobs feature. You can create jobs, each of them representing a sequence of actions described using 1C:Enterprise script. You can create a schedule for each job to have it executed automatically in compliance with the schedule.
In this lesson you will study the jobs using two scheduled operations related to the full-text search: full-text indexing and index merging.
You will describe these operations using 1C:Enterprise script, as well as create schedules for automatic execution.
In the previous lesson you learned that a full-text index is required to enable full-text search. A full-text index is only created once and should be updated regularly.
In reality, a full-text index includes two indexes: main and supplementary. When a full-text search is performed, both indexes are searched. The difference is as follows.
The main index is designed to ensure maximum search speed with large data volume. But the disadvantage is that data is added to the main index quite slowly.
The supplementary index is a direct opposite of the main index: data is added to the supplementary index fast but if the data volume in the supplementary index is significant, the search is performed relatively slowly.
The availability of the main and supplementary indexes suggests the following usage strategy. The majority of data is located in the main index, which enables quite a rapid search. New data (either modified or added) is added to the supplementary index in real time with a required periodicity (for example, once per hour or every minute). Data is added rapidly and does not influence the system performance significantly. While the supplementary index does not contain a large volume of data, search in this index is also performed rapidly.
In the periods of low user activity or when scheduled infobase operations are performed (often in the night), the main index is merged with the supplementary index (this can be done once a day). This operation might generate noticeable load or take a long time (depending on the amount of data accumulated). As a result, new data is moved to the main index while the supplementary index is cleared and prepared for quick filling with new data.
To enable users to search in all the data without impacting the system performance, the supplementary index should be updated quite frequently (for example, once per hour or every minute). Besides, to keep the search rapid enough, the supplementary index should contain as little data as possible, hence the main index should be merged with the supplementary index regularly (for example, in the night during the minimum user activity period).
So to automate full-text indexing, you need two jobs. The first job will perform indexing without merging and will be executed every minute. The second job will merge indexes and will be executed once a day in the night.
Let us proceed to creating the jobs.