-
Notifications
You must be signed in to change notification settings - Fork 4
Why limit the number of selected columns
Selected columns that you don't need can impact performance, particularly when you select all columns.
Not selecting everything can save memory in the database and JVM sides and reduce IO between the JVM and the database.
Also, unwanted columns can prevent some index-only scans that avoid table access, saving a lot of IO. Preventing index-only scans can seriously limit performance.
We invite you to view a part of this talk from Lukas Eder and Vlad Mihacea (to 56:00). It explains some negative impacts of selecting too many columns.
When you need some specific read-only data, as could be the case with DTOs, it is recommended to project the necessary columns. Examples can be found here or here to do this with JPA, Hibernate, or Spring.
With the ExpectSelectedColumn QuickPerf annotation, we can quickly check the number of selected columns.
π Β Core
π Β JVM
π Β SQL
π Β Scopes
π Β Create an annotation
π Β JUnit 4
π Β JUnit 5
π Β TestNG
π Β Spring
π Β Detect and fix N+1 SELECT
π Β Maven performance
π Β Spring Boot - JUnit 4
π Β Spring Boot - JUnit 5
π Β Micronaut Data - JUnit 5
π Β Micronaut - Spring - JUnit 5
π Β Quarkus - JUnit 5
π Β FAQ
π Β QuickPerf code