원클릭으로
query-optimize
For optimizing slow 1C queries and DCS datasets
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
For optimizing slow 1C queries and DCS datasets
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
When writing or reviewing BSL, apply 1C standards
При написании или ревью BSL применять стандарты 1С
Orchestrator: routing work and agent phases
Оркестратор: маршрутизация работы и фаз агентов
BSL LSP navigation: definitions, refs, call graph
Rules for using RLM tools for project search and navigation in 1C/BSL
SOC 직업 분류 기준
| name | query-optimize |
| description | For optimizing slow 1C queries and DCS datasets |
| target_agents | ["developer-code","architect"] |
| alwaysApply | false |
A skill for optimizing existing queries and data composition schemas. For writing queries from scratch, use query-patterns. For DBMS diagnostics (plan, locks, evidence), use db-performance.
db-performance ← lower evidence layer (DBMS evidence, plan, locks)
↓ passes query + reason
query-optimize ← rewriting (this skill)
↓ uses writing rules
query-patterns ← basic patterns (parameterization, NULL, loops)
Without db-performance evidence, optimization is a guess. If the reason is unknown, start with db-performance.
rg "Запрос.Текст\s*=" --type-add "bsl:*.bsl" -t bsl.xml via code-navigation, determine the datasetBefore rewriting, check the metadata object structure:
Tool: code-navigation → object structure.
Choose from the categories (one per iteration):
| Reason | Sign |
|---|---|
| Broad virtual table read | Остатки() / Обороты() without period or dimension parameters |
| Query-in-loop | Query inside Для Каждого / Пока / recursion |
| Dot-dereference without ВЫРАЗИТЬ | Движения.Регистратор.Контрагент for a composite type |
| Excess temporary tables | Intermediate tables with the full field set instead of the minimum |
| Extra totals | ИТОГИ in a query when a flat result set is needed |
| Filtering after join | ГДЕ conditions on fields of a large table instead of virtual table parameters |
| Implicit row multiplication via JOIN | LEFT JOIN without aggregation duplicates rows |
| DISTINCT masks the problem | ВЫБРАТЬ РАЗЛИЧНЫЕ hides an extra JOIN instead of fixing it |
For each cause, use a specific rule (see the “Rules” section below).
v8-runner after any changeРАЗРЕШЕННЫЕ filters; security rules must remain intactIf the change affects the DBMS plan (index, virtual table parameters, join type), ask the user for EXPLAIN / ТЖ before and after. Without measurement, record it as “expected effect, requires verification”.
The concrete “how to write it correctly” rules are canonical in query-patterns. Here is the mapping from the cause (step 3) to the rule from query-patterns; apply the rule from there, do not duplicate query patterns in this skill.
| Cause (step 3) | query-patterns rule |
|---|---|
| Broad virtual table read | Rule 5 — put period/dimension parameters inside the virtual table, not in ГДЕ |
| Query-in-loop | Rule 1 — one query + Соответствие for access |
Dot-dereference without ВЫРАЗИТЬ | Rule 12 — ВЫРАЗИТЬ(… КАК …) + ССЫЛКА for a composite type |
| Excessive temp tables / no join index | Rules 2, 8 — minimal fields, ИНДЕКСИРОВАТЬ ПО only on the join field |
| Redundant totals | Rule 16 — ИТОГИ only for Выбрать(ПоГруппировкам), otherwise СГРУППИРОВАТЬ ПО |
| Filtering after join | Rules 5, 13 — VT parameters / ПО vs ГДЕ |
РАЗЛИЧНЫЕ masks an extra JOIN | Rule 11 — subquery В (…) instead of JOIN + РАЗЛИЧНЫЕ |
Optimization specifics (beyond the general query-patterns rules):
WHERE)INDEX BY)CAST before dot dereferenceLEFT JOIN does not turn into INNER JOIN because of a condition in WHEREDISTINCT does not mask an extra JOINALLOWED and other rights filters are preservedALLOWED without explicit security approval.db-performance.depends_on: