Skip to content

[FEATURE REQUEST] Pull TVP name from SQLServerDataTable to avoid execution of sp_sproc_columns_100 #1281

@Logic-32

Description

@Logic-32

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementAn enhancement to the driver. Lower priority than bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions