Java Resultset.get *** (...) faster with string or int?

When you restart using the result set

while (rs.next()){
...
}

To get column data (e.g. long), it’s faster to use

rs.getLong(String columnLabel)

or

rs.getLong(int columnIndex)

Presumably, columnLabel is better used in many ways for stronger code, but are there any significant losses during operation, each time comparing columns with a row (we are talking about table sizes ~ 40 m rows)?

+3
source share
4 answers

I would bet that compared to the cost of preparing a set of results, the difference is careless. Favorable code.

+3
source

! .

- , .

1. , , . : . iLast_Name.

2. , . "Last_Name" 3, "iLast_Name" 3.

3. GET/SET. / , , .

. ( ) , .

+1

, , , .

: , , select * from ...., ResultSet, String a = resultSet.getString(1), int i = resultSet.getInt(2) .. ..

, ... , int. , .

, . , , , .

0

. - , . -, . , , . , , , .

0

Source: https://habr.com/ru/post/1759870/


All Articles