Virtual table call without parameters (VirtualTableCallWithoutParameters)¶
Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
---|---|---|---|---|---|
Error |
BSL |
Major |
Yes |
5 |
sql standard performance |
Description¶
When using virtual tables in queries, you should specify all conditions related to it in the table parameters.
It is not recommended to refer to virtual tables using conditions in the WHERE section, etc.
Such a query will return the correct (in terms of functionality) result, but it will be much more difficult for the DBMS to choose the optimal plan for its execution. In some cases, this can lead to errors in the DBMS optimizer and a significant slowdown in query performance.
Examples¶
For example, a query uses the WHERE
section to filter virtual table data:
Query.Text = "SELECT
| Good
|FROM
| AccumulationRegister.MyGoods.Turnovers()
|WHERE
| Warehouse = &Warehouse";
It is recommended that you limit the number of selected records as early as possible. To do this, pass conditions to the parameters of the virtual table.
Query.Text = "SELECT
| Good
|FROM
| AccumulationRegister.MyGoods.Turnovers(, Warehouse = &Warehouse)";
Sources¶
- Standard: Using virtual tables (RU)
- Standard: Effective use of the virtual table «Turnovers» (RU)
- 1C Recommendation: Using the Condition parameter when accessing a virtual table (RU) (RU)
Snippets¶
Diagnostic ignorance in code¶
// BSLLS:VirtualTableCallWithoutParameters-off
// BSLLS:VirtualTableCallWithoutParameters-on
Parameter for config¶
"VirtualTableCallWithoutParameters": false