-
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 performances, particularly when you select all columns.
Unwanted columns can prevent some index-only scans that avoid table access, and so saves a lot of IO. This can seriously degrade performances.
In addition, according to Markus Winand: "Besides Index-Only Scans, not selecting everything can also improve sorting, grouping and join performance because the database can save memory that way."
We can add that reducing selected columns to what you need can reduce the memory presssure on JVM side together with the IO between the JVM and the database.
So, when you need some specific read-only data, as it could be the case with DTOs, it is recommended to project the needed columns. Examples can be found here to do this with JPA, Hibernate or Spring.
π Β 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