Skip to content

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";
When executing this query, first all records of the virtual table will be selected, then the part corresponding to the specified condition will be selected from them.

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

Snippets

Diagnostic ignorance in code

// BSLLS:VirtualTableCallWithoutParameters-off
// BSLLS:VirtualTableCallWithoutParameters-on

Parameter for config

"VirtualTableCallWithoutParameters": false