[New-bugs-announce] [issue32215] sqlite3 400x-600x slower depending on formatting of an UPDATE statement in a string

Brian Forst report at bugs.python.org
Mon Dec 4 19:40:53 EST 2017


New submission from Brian Forst <bforst at gmail.com>:

We're moving some code from Python 2.7 to 3.6 and found a weird performance issue using SQLite in-memory and on-disk DBs with the built-in sqlite3 library. In Python 2.7, the two update statements below (excerpted from the attached file) run in the same amount of time. In Python 3.6 the update statement with the table name on a separate line runs 400x-600x slower with the example data provided in the file.

"""
UPDATE tbl
SET col2 = NULL
WHERE col1 = ?
"""

"""
UPDATE
  tbl
SET col2 = NULL
WHERE col1 = ?
"""

We have verified this using Python installs from python.org on macOS Sierra and Windows 7 for Python 2.7 and 3.6.

We have tried formatting the SQL strings in different ways and it appears that the speed change only occurs when the table name is on a different line than the "UPDATE".

This also appears to be hitting some type of quadratic behaviour as with 10x less records, it only takes 10-15x as long. With the demo in the file we are seeing it take 1.6s on the fast string and ~1000s on the slow string.

----------
components: Interpreter Core, Library (Lib)
files: sqlite3_27_36_performance_bug.py
messages: 307609
nosy: bforst
priority: normal
severity: normal
status: open
title: sqlite3 400x-600x slower depending on formatting of an UPDATE statement in a string
type: performance
versions: Python 2.7, Python 3.6
Added file: https://bugs.python.org/file47315/sqlite3_27_36_performance_bug.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32215>
_______________________________________


More information about the New-bugs-announce mailing list