📜 ⬆️ ⬇️

Making SQL service plans for 1C: Enterprise 8.x

After another request to tell how to make a plan for servicing the sql-bases used by 1C: Enterprise , I decided to share the experience with everyone at once.
Why this is necessary - if the sql does not serve the database, then its meaning is lost altogether. The main tool is indexes and they should be kept up to date. I did not meet any dogmas not in practice, not in the net, not in courses in 1C itself, and therefore I share my experience.

Often the base works in “normal” conditions. What is meant by this:

It is also worth considering a few nuances:

It is rational under normal conditions to use 2 Weekly maintenance plans (once a week) and Daily (on the remaining 6 days of the week).

Weekly

General form
image

By service plan items:
  1. Rebuilding index. The meaning of the task is to remove all existing indexes and install new ones. (roughly speaking, the inventory and the arrangement of everything in order).
    As parameters:
    • The choice of the target database (this will be in almost all tasks, because I will not pay attention to this parameter further within this article).
    • The object in which we select "Tables and Views."
    • Free space options - if the hard disk is small, you can select the “default” option, but I recommend using the “Change free space on page” option, the recommended value is 20%. This will leave a stock of free pages, and will allow longer indexes to keep up to date. ATTENTION: Increases the size of the database.
    • Sort results in tempdb. I think it is not necessary to explain, but I want to warn, at this time tempdb, will grow very much, although sorting in it is intended to speed up the process, be careful, keep a space.
    • Save the index in the "online" mode - a chip available for the enterprise version of SQL. Allows you to re-index without disconnecting clients.
    !!! ATTENTION!!! In the Standard version, when reindexing, clients are disconnected from the database for the duration of this step.
    Settings example
    image
  2. Update statistics. The task of collecting information about the status of indices in the database. (In general, it is not very relevant after reindexing, but still I do).
    Options:
    • An object. All the same tables and views as for rebuilding the index.
    • Refresh. Here we update all the statistics.
    • View Type - Full View.
    Thus, we update the statistics for the entire database.
    Settings example
    image
  3. Execute T-SQL statement. This execution of an arbitrary command in the SQL language, in particular, interests us
    dbcc proccache 
    As the name implies - clearing the cache.
    Example
    image
  4. Check the integrity of the database. There seems to be no explanation - make sure that nothing is broken. In the parameters "include indexes" in the test, not for nothing that was rebuilt.
    Settings example
    image
  5. Backup database. Here we need to talk more, in view of many features. It is better to study this item separately independently in other manuals, the format of this article does not provide for an in-depth study of backup.
    But I want to warn about a couple of nuances:
    • SQL does not know how to clean its container, so if you add backups to a file (it is called “Backup Device”), you will eventually clog up all the free space.
    • SQL remembers their backups, because by making one-time backup handles (for example, take the database to another location, or to deploy for a test to another database from the backup), the next “difference” will be counted from it. In order to prevent this, you need to tick "Backup only". There is no such item in the backup task. In general, in the weekly plan I recommend to use the full type of backup.
    • And it would be good to check the copy, let it sleep better.
    • Compression, in general, can be used, but be careful, then differential should also be compressed.
    Settings example
    image
  6. Clearing the log.
    • Backup log and restore.
    • SQL Server Agent Job Log
    • Service plan log.
    I clean everything. As the name implies, cleans events in the SQL log. I believe that events older than 4 weeks are unlikely to interest me, because if there is a problem, then report it within a month.
    Settings example
    image
  7. Operator notification. Fad again for self-study. But as the name implies, for reporting problems during the implementation of the plan.

')

Daily

General form
image
Speaking separately does not make sense. Almost everything is similar to Weekly.
The difference in the first task is “Index reorganization”. Tasks are different in that the reorganization is trying to rectify the existing indices, and does not do everything from scratch. The greater the fragmentation, the more often it will cost to run. But in normal conditions, once a day is enough to keep the index up to date until the next rebuilding.
Options
image
You can also use differential backups.

That's all. I repeat, I did not see dogmas in this moment, this version was developed and tested by me. Actually for bases from 6 to 100 GB in size.

I wish you fast and reliable work.
PS Due to the fact that I am not a full-fledged DBA, perhaps my comments are very superficial, I’m happy to read the comments in the comments and the PM.

Source: https://habr.com/ru/post/158433/


All Articles