framework_eng/skills/tool-usage/diagnostics/db-performance/SKILL.md
Diagnostics of slow queries, locks, and DBMS execution plans
npx skillsauth add steelmorgan/1c-agent-based-dev-framework db-performanceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The skill works at two levels simultaneously: the 1С platform (query, metadata, SCD) and the DBMS (plan, locks, waits, temp storage). A diagnosis without both levels is incomplete.
| Symptom | First step |
|---------|-----------|
| Slow report / posting / exchange | Step 1: name the scenario |
| SQL in the tech log with a large Duration | Step 2: extract the query + metadata |
| Locks TLOCK / TDEADLOCK | Step 3: collect DBMS evidence |
| TEMPDB/WAL grows during a "read-only" scenario | Steps 3-4: red flags + causes |
| The table grew and the report became slower | Full algorithm (steps 1-5) |
This skill is the lower evidence layer. For rewriting the query text or SCD, pass it to query-optimize.
| Task | Tool |
|--------|-----------|
| Find the query in code | rg (ripgrep) over BSL text |
| Navigate to a symbol / procedure | code-navigation |
| Get SQL from the tech log | tech-log-analysis → search_tech_log with name: DBMSSQL / DBPOSTGRS |
| Run a test / syntax check | v8-runner |
| Metadata information | code-navigation → register / catalog structure |
There is no direct access to EXPLAIN ANALYZE, pg_stat_statements, sys.dm_exec_query_stats - instructions for obtaining them are passed to the user/administrator.
Precisely determine: what the user does / which background process / which exchange step / which report with which filters. Without a concrete scenario, diagnosis is impossible.
Record: name, expected time, actual time, conditions (data volume, company, period).
Platform layer:
rg "Запрос.Текст\s*=" --type-add "bsl:*.bsl" -t bsl.xml data composition schema through code-navigationRequirement: the 1C query text must always be paired with at least one DBMS artifact (step 3). Analysis of the query text alone, without DBMS evidence, does not provide an evidence base.
Evidence categories (at least one is required):
| Category | PostgreSQL | MS SQL Server | What it proves |
|-----------|-----------|---------------|----------------|
| Query plan | EXPLAIN (ANALYZE, BUFFERS) | SET STATISTICS IO, TIME ON + actual plan | Seq scan vs index scan, hash join cost, actual rows |
| Locks / waits | pg_locks, pg_stat_activity | sys.dm_exec_requests, sys.dm_os_waiting_tasks | Lock holder, waiter, lock type |
| Temp storage | WAL size, pg_stat_bgwriter | TEMPDB usage, VLF count | Hidden writes during a "read-only" scenario |
| Table statistics | pg_stat_user_tables | sys.dm_db_index_usage_stats | Seq scans vs index seeks, stale stats |
| Tech log artifacts | DBPOSTGRS events | DBMSSQL events | Duration, SQL text, context |
File-based infobase is a separate model: there is no DBMS plan, and performance is determined by the structure of dbf files and platform locks.
Missing evidence rule: if a DBMS artifact cannot be obtained, record it explicitly: "DBMS evidence is absent, reason: <...>". Do not replace it with assumptions.
Classify the cause by category:
| Category | Signs |
|-----------|---------|
| Inefficient query | Seq scan on a large table, no filter in a virtual table, dot dereference without ВЫРАЗИТЬ |
| Missing / harmful index | Full table scan on a field without an index; or an index exists but is not used because of the condition type |
| Wide read of a virtual table | Остатки() without period / dimension parameters |
| Query-in-loop | N queries for N rows: Duration * N in the tech log, repeated SQL with different parameters |
| Lock contention | TLOCK / TDEADLOCK in the tech log; blocking query in pg_locks / sys.dm_exec_requests |
| DBMS maintenance | Autovacuum, index rebuild, stale statistics - the plan degraded |
| Data growth | The query is correct, but the table volume grew - the plan changed |
One cause per iteration. If there are multiple causes, start with the most likely one based on evidence.
v8-runnerРАЗРЕШЕННЫЕ and do not disable RLS/permission filters for performance without explicit security approval.EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)rows=, high shared hit with low actual rowswork_mem overflow → temp file in the plan → WAL pressurepg_stat_activity.wait_event_type = 'Lock'SET STATISTICS IO ONtempdb.sys.dm_db_task_space_usagesys.dm_exec_requests.blocking_session_idTLOCK)## Scenario and evidence
<Scenario: ...>
<DBMS evidence: plan / tech log / absent (reason)>
## Root cause (in descending order of likelihood)
1. <Category> — <fact from evidence>
2. ...
## Change
<One specific change: text / index / parameter>
<Expected measurable effect>
## Verification
<How to measure: command / scenario / tech log comparison>
## Residual risks
<Data volume / locks / DBMS-specific behavior>
depends_on:
development
1C server maintenance webhooks: container restart and external component cache cleanup
development
Interactive DAP debugging of a single BSL procedure
tools
Rules for using RLM tools for project search and navigation in 1C/BSL
development
Creates web applications and routes on Winow (a web server on OneScript and Autumn). Use when working with a web server on OneScript, routing, or Winow controllers.