Open arhnabri opened 1 year ago
All filtered columns should be indexed
Add @Index on @ManyToOne, @OneToMany, @ManyToMany or @OneToOne. Primary keys (@Id aren't concerned)
<p>Spring Data, avoid usage of joints on non primary keys or non Indexed columns. <br> The purpose is to avoid consuming unnecessary resource to collect data</p> <h2>Noncompliant Code Example</h2> <pre> @Entity class MyEntity { @ManyToOne private MyEntity subEntities; // Noncompliant {{Add @Index on foreign key}} @OneToMany private List<String> subEntity4; // Noncompliant {{Add @Index on foreign key}} } </pre> <h2>Compliant Solution</h2> <pre> @Entity class MyEntity { @ManyToOne @Index(name = "indexSubEntity2", columnNames = "subEntity2Id") private MyEntity subEntities2; @OneToMany @Index(name = "indexSubEntity3", columnNames = "subEntity3Id") private List<String> subEntity3; } </pre>
Built by team 2 millions.
Interesting idea but missing documentation or measure to justify it. May be we should try to measure it in the next hackaton.
Index filtered database columns
Platform
Main caracteristics
Severity / Remediation Cost
Rule short description
All filtered columns should be indexed
Rule complete description
Text
Add @Index on @ManyToOne, @OneToMany, @ManyToMany or @OneToOne. Primary keys (@Id aren't concerned)
HTML
Implementation principle