sql

All things SQL and JDBC...
Ben Sless 2021-06-21T17:33:11.242700Z

Looks like my builder macro worked. So now for some more black magic - can I make any assumptions regarding the order in which the columns return? getObject(String) is slower than getObject(int)

seancorfield 2021-06-21T17:37:23.244300Z

@ben.sless Well, the columns are in a particular order — the “natural” query order — but your builder can’t know that without going into the ResultSetMetaData and getting the column names (which seems to be part of what you are trying to avoid).

Ben Sless 2021-06-21T17:39:24.245300Z

Maybe I can do it once then cache the result, unless that can theoretically change every time I run the query? My queries are pretty static, if it makes any difference

seancorfield 2021-06-21T17:41:16.245700Z

The order should match the query.

Ben Sless 2021-06-21T17:41:25.246Z

select *

seancorfield 2021-06-21T17:41:29.246200Z

Ugh!

Ben Sless 2021-06-21T17:41:36.246500Z

tell me about it

seancorfield 2021-06-21T17:42:09.247300Z

select’ing explicit column names is going to be better/faster than * (which requires some level of introspection).

seancorfield 2021-06-21T17:42:31.248Z

(on both sides of the SQL/JDBC boundary!)

Ben Sless 2021-06-21T17:43:03.248500Z

I'm aiming at minimal friction with the existing code base

Ben Sless 2021-06-21T17:43:22.249Z

But it looks like * returns the columns in the order they are specified when creating the table

Ben Sless 2021-06-21T17:43:47.249200Z

cooking with gas / 10