framework_eng/skills/tool-usage/diagnostics/db-performance/SKILL.md
1С database and query performance diagnostics. Use when you need to diagnose a slow scenario, slow query, DBMS plan, locks, deadlock, TEMPDB/WAL, table sizes, or SCD on large data.
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.
This skill works on two levels at once: 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 |
| Table grew - the report became slower | Full algorithm (steps 1-5) |
This skill is the lower evidence layer. For rewriting query text or SCD, hand it off to query-optimize.
| Task | Tool |
|--------|-----------|
| Search for a 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 |
| Test run / syntax check | v8-runner |
| Metadata information | code-navigation → register / catalog structure |
There is no direct access to EXPLAIN ANALYZE, pg_stat_statements, or sys.dm_exec_query_stats - instructions for obtaining them are passed to the user/administrator.
Precisely determine: what the user is doing / which background process / which exchange step / which report with which filters. Without a specific scenario, diagnosis is impossible.
Record: name, expected time, actual time, conditions (data volume, organization, period).
Platform layer:
rg "Запрос.Текст\s*=" --type-add "bsl:*.bsl" -t bsl.xml data composition schema via code-navigationRequirement: the 1С query text must be paired with at least one DBMS artifact (step 3). Analysis of the query text alone without DBMS evidence does not provide a basis for proof.
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 in 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, performance is determined by the structure of dbf files, locking is handled by the platform manager.
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, missing filter in a virtual table, dot dereference without ВЫРАЗИТЬ |
| Missing / harmful index | Full table scan on a field without an index; or the index exists, but is not used because of the condition type |
| Broad virtual table read | Остатки() 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, statistics are stale - the plan has degraded |
| Data growth | The query is correct, but the table volume has grown - the plan changed |
One cause per iteration. If there are multiple causes, start with the most likely one according to the evidence.
v8-runnerРАЗРЕШЕННЫЕ and do not disable RLS/rights filters for the sake of performance without explicit security approval.EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)rows=, high shared hit with low actual rowswork_mem overflows -> 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 details>
depends_on:
testing
MUST use BEFORE making a judgment about the cause of a conflict, a test failure, or an artifact dispute. Defines the end-to-end verification method L1→L6 and the classification of the first broken link.
development
MUST use AFTER a work cycle with ≥2 iterations (wrote → error → fixed → success). Provides the retrospective procedure and the format for recording practice/anti-patterns in references/learned-patterns.md or {project}/.context/learned-patterns.md.
tools
MUST use WHEN you are writing reusable knowledge into RLM (pattern / architectural decision / stable domain fact) OR reading it before a non-trivial task/solution in the domain. Provides the breakdown of native-push vs RLM-pull, tools for writing and reading RLM, H-MEM levels, and hygiene.
testing
MUST use WHEN the task is classified as simple (< 20 lines, 1 file, no new metadata objects, no architectural decisions). Provides a short cycle of 3 steps with a guard on the self path and mandatory verify.