New submission from Brian Forst <bfo...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue32215>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to