When selecting many fields, a lot of CPU is consumed because the fields are looped.
In one case I encountered, with a select of millions of records with about 700 fields, I forced the query to stop because it was consuming 100% CPU for several hours.
At this time, I checked Java's stack trace many times, and most of them were processing the following for statement.
|
for (int i = 0; i < this.fields.size(); i++) { |
|
RowDescription.Field field = this.fields.get(i); |
|
|
|
if (field.getName().equalsIgnoreCase(name)) { |
|
return i; |
|
} |
|
} |
Would it be possible to prepare field name and order mappings in advance?
When selecting many fields, a lot of CPU is consumed because the fields are looped.
In one case I encountered, with a select of millions of records with about 700 fields, I forced the query to stop because it was consuming 100% CPU for several hours.
At this time, I checked Java's stack trace many times, and most of them were processing the following for statement.
r2dbc-postgresql/src/main/java/io/r2dbc/postgresql/PostgresqlRow.java
Lines 168 to 174 in d047276
Would it be possible to prepare field name and order mappings in advance?