SA0181 : The query joins too many table sources

The topic describes the SA0181 analysis rule.

Message

The query joins too many table sources

Description

The rule reports queries that joins more than the configured maximum number of table sources.

How to fix

Reviwe the query, refactor it if possible.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters
Name Description Default Value
MaxTableSources

Maximum number of table sources, which can be joined in a query.

5

Remarks

The rule does not need Analysis Context or SQL Connection.

Effort To Fix
3 hours per issue.
Categories

Design Rules, Code Smells

Additional Information

There is no additional info for this rule.

Example Test SQL
SQL
 1delete from Table_1
 2from Table_1 as t1
 3     join Table_2 as t2
 4                  on  ltrim( t1.testdata1 ) = substring( t2.testdata1 ,
 5                                                         1 ,
 6                                                         1 ) ,
 7     Table_3 as t3 ,
 8     Table_4 as t4
 9     inner join Table_5 as t5
10                  on  t4.t5id = t5.id ,
11     Table_6 as t6 ,
12     Table_7 as t7
13
14
15update Table1 set col1 = 0
16from Table_1 as t1
17     join Table_2 as t2
18                  on  ltrim( t1.testdata1 ) = substring( t2.testdata1 ,
19                                                         1 ,
20                                                         1 ) ,
21     Table_3 as t3 ,
22     Table_4 as t4
23     inner join Table_5 as t5
24                  on  t4.t5id = t5.id ,
25     Table_6 as t6 ,
26     Table_7 as t7
27
28select *
29from Table_1 as t1
30     join Table_2 as t2
31                  on  ltrim( t1.testdata1 ) = substring( t2.testdata1 ,
32                                                         1 ,
33                                                         1 ) ,
34     Table_3 as t3 ,
35     (select c1, c2 from Table_4) as t4
36     inner join Table_5 as t5
37                  on  t4.t5id = t5.id ,
38     Table_6 as t6 ,
39     Table_7 as t7

Analysis Results
  Message Line Column
1 SA0181 : The query joins too many table sources. 1 0
2 SA0181 : The query joins too many table sources. 15 0
3 SA0181 : The query joins too many table sources. 28 0
See Also

Other Resources