1c-query-optimization

Optimizes 1C:Enterprise query language code using temporary tables, joins, and DCS patterns.

Updated Jun 26, 2026
One-click install
npx skills add https://github.com/pavelvdo/universal-xml-exchange2 --skill 1c-query-optimization-pavelvdo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 1c-query-optimization
Source: https://github.com/pavelvdo/universal-xml-exchange2/tree/main/.cursor/skills/1c-query-optimization
Command: npx skills add https://github.com/pavelvdo/universal-xml-exchange2 --skill 1c-query-optimization-pavelvdo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Slow 1C:Enterprise queries caused by subqueries in SELECT, unfiltered virtual tables, composite type dereferencing, and OR conditions that bypass indexes degrade application performance and are hard to diagnose without platform-specific knowledge. ## Core Features & Use Cases - Query Pattern Library: Provides ITS-standard patterns for temporary tables, join vs subquery decisions, virtual table parameters, and ОБЪЕДИНИТЬ ВСЕ usage with side-by-side slow/fast BSL examples. - DCS Optimization: Covers Data Composition System report queries including parameter passing, source-level filtering, and ЕСТЬNULL handling for outer joins. - Index Alignment Guidance: Explains index usage rules (field order, gaps, ИНДЕКСИРОВАТЬ ПО for temporary tables) so conditions actually hit available indexes. - Use Case: A report on register balances runs slowly because it joins a virtual table directly and dereferences a composite Регистратор field. Apply the skill to extract the virtual table into an indexed temporary table and use ВЫРАЗИТЬ to cast the registrar to a concrete document type. ## Quick Start Ask the assistant to review and optimize a slow 1C query using the 1c-query-optimization skill, pasting the query text you want improved.

Frequently Asked Questions about 1c-query-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize a slow 1C query with subqueries?

Replace subqueries in SELECT or JOIN clauses with temporary tables. Write the aggregated or filtered data into a temporary table with ПОМЕСТИТЬ, add ИНДЕКСИРОВАТЬ ПО on join fields, then join the main query against it.

How to filter virtual tables in 1C queries for better performance?

Pass filter conditions as virtual table parameters instead of using WHERE after the table. For example, Остатки(&Дата, Номенклатура В (&Список)) filters at the source, while a WHERE clause forces the platform to materialize all rows first.

Why is dereferencing composite type fields slow in 1C?

Dereferencing a composite reference like Регистратор.Дата makes the platform generate queries for every possible document type. Use ВЫРАЗИТЬ to cast the field to one concrete type, or ВЫБОР/КОГДА with ССЫЛКА checks for a few known types.

Should I use ОБЪЕДИНИТЬ or ОБЪЕДИНИТЬ ВСЕ in 1C queries?

Use ОБЪЕДИНИТЬ ВСЕ when duplicate rows are not expected, because plain ОБЪЕДИНИТЬ performs an extra grouping pass to remove duplicates. Reserve ОБЪЕДИНИТЬ only for cases where deduplication is actually required.

Why does OR in a WHERE clause slow down 1C queries?

OR conditions prevent index usage, forcing full table scans. Split the condition into separate indexed queries combined with ОБЪЕДИНИТЬ ВСЕ so each branch can use its own index.

When should I not use this query optimization skill?

For basic query rules like formatting, aliases, parameters, and avoiding queries in loops, use the base coding standards document instead. This skill covers only advanced patterns beyond those fundamentals.