Is your feature request related to a problem? If so, please give a short summary of the problem and how the feature would resolve it
We use a lot of TVPs via PreparedStatement.setObject(). Often times, we're able to do this by passing in a SQLServerDataTable instance but rarely are we ever able to use SQLServerPreparedStatement.setStructured(). This causes SQLServerPreparedStatement to forcibly report the tvpName as null and then execute a query to load the tvpName (sp_sproc_columns_100 for modern SQL Servers). The execution of that query happens ends up executing about 1.4 million times per hour and causes a high CPU as a result.
Describe the preferred solution
In situations were we can still infer the tvpName without using setStructured(), such as when a SQLServerDataTable is passed in, use the provided tvpName.
Describe alternatives you've considered
We could alternatively use SQLServerPreparedStatement.setStructured(). That requires calling unwrap() on the PreparedStatement we have which breaks a metrics utility we use. Additionally, the problem is further complicated by frameworks like JdbcTemplate and Apache QueryRunner which may not provide access to the underlying SQLServerPreparedStatement but still accept SQLServerDataTable instances.
Additional context
This information was gained by querying sys.dm_exec_query_stats in SQL Server 2014.
Is your feature request related to a problem? If so, please give a short summary of the problem and how the feature would resolve it
We use a lot of TVPs via
PreparedStatement.setObject(). Often times, we're able to do this by passing in aSQLServerDataTableinstance but rarely are we ever able to useSQLServerPreparedStatement.setStructured(). This causes SQLServerPreparedStatement to forcibly report the tvpName as null and then execute a query to load the tvpName (sp_sproc_columns_100 for modern SQL Servers). The execution of that query happens ends up executing about 1.4 million times per hour and causes a high CPU as a result.Describe the preferred solution
In situations were we can still infer the
tvpNamewithout usingsetStructured(), such as when aSQLServerDataTableis passed in, use the providedtvpName.Describe alternatives you've considered
We could alternatively use
SQLServerPreparedStatement.setStructured(). That requires callingunwrap()on the PreparedStatement we have which breaks a metrics utility we use. Additionally, the problem is further complicated by frameworks like JdbcTemplate and Apache QueryRunner which may not provide access to the underlyingSQLServerPreparedStatementbut still acceptSQLServerDataTableinstances.Additional context
This information was gained by querying sys.dm_exec_query_stats in SQL Server 2014.