Skip to content

Passing None to SQL Server INSERTs drastically slows down inserts: #741

@nelsonwcf

Description

@nelsonwcf

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:

  • Python: 3.7.7
  • pyodbc: 4.0.30
  • OS: Windows 10 x64 [Version 10.0.18362.720]
  • DB: SQL Server 13.0.5698.0
  • driver: ODBC Driver 17 for SQL Server (2017.175.01.01)

Issue

There's a drastic slow down in parameterized inserts when None/Nan are present in the list, usually of two magnitudes.

I already browsed through through issue #213 but it's old and still open. I also read through https://github.com/mkleehammer/pyodbc/wiki/Binding-Parameters, which gave me the idea to replace the None in the first line with valid data, which somewhat fixes the issue (but forces me to run an update query at the end of the INSERT statement to fix the 'substitute' NULLs).

Also, I've tried pyodbc.set_none_binding(pyodbc.SQL_VARCHAR) as suggested in the Proposal 1 workaround but the current pyodbc doesn't recognize this a property or method.

What is the current status of the NULL/None issue when inserting in SQL Server? Are there any developments?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions