I have some issues regarding the understanding of "ResultSet". If I want to measure the performance time it take to execute the query, do I need to iterate through the Resultset --> while(rs.next()), since the actual result set includes already has all the results? Or is it more like a buffer that while iterating through the ResultSet some tuple just get generated?
Statement b = conn.createStatement();
ResultSet rs2 = b.executeQuery("Select o_orderkey, o_orderstatus, o_orderdate, o_orderpriority, o_comment from orders");
while(rs2.next()){
int okey=rs2.getInt(1);
String st=rs2.getString(2);
Date dt=rs2.getDate(3);
String pr=rs2.getString(4);
String co=rs2.getString(5);
}
long endTime = System.currentTimeMillis();
System.out.println(i+". DuckDB " + (endTime- startTime) +" ms");
For this example there is a huge difference in performance. When I only measure the time it needs to build the ResultSet without the while loop it's only a fraction of time. That's why I was thinking it could depend on the database, since DuckDB goes vectorized through the database.
My question is now which way is the correct one, when I only want to have the time it takes to answer the query?