Skip to content

Why limit the number of selected columns

Jean Bisutti edited this page Nov 18, 2020 · 4 revisions

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.

Annotations

πŸ‘‰ Β Core

πŸ‘‰ Β JVM

πŸ‘‰ Β SQL

πŸ‘‰ Β Scopes

πŸ‘‰ Β Create an annotation

Supported frameworks

πŸ‘‰ Β JUnit 4

πŸ‘‰ Β JUnit 5

πŸ‘‰ Β TestNG

πŸ‘‰ Β Spring

How to

πŸ‘‰ Β Detect and fix N+1 SELECT

Project examples

πŸ‘‰ Β Maven performance

πŸ‘‰ Β Spring Boot - JUnit 4

πŸ‘‰ Β Spring Boot - JUnit 5

πŸ‘‰ Β Micronaut Data - JUnit 5

πŸ‘‰ Β Micronaut - Spring - JUnit 5

πŸ‘‰ Β Quarkus - JUnit 5

Miscellaneous

πŸ‘‰ Β FAQ

πŸ‘‰ Β QuickPerf code

Clone this wiki locally