This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author feuermurmel
Recipients feuermurmel
Date 2010-07-19.12:08:03
SpamBayes Score 0.0036763889
Marked as misclassified No
Message-id <1279541286.68.0.824716490463.issue9303@psf.upfronthosting.co.za>
In-reply-to
Content
The Python sqlite module currently uses some deprecated API [0] of SQLite. These are functions that have a counterpart with _v2 appended to their name.

The SQLite query planner will not use certain optimizations when using the old API. For example, as documented in [1], using a statement with a GLOB or LIKE operator where the pattern is parametrized will only use an appropriate index if sqlite3_prepare_v2() is used instead of sqlite3_prepare().

Following is an example of such a query. When executed, table 'test' is scanned row by row, which requires all data in the table to be loaded from disk.

cursor.execute('create table test(a text)')
cursor.execute('create index test_index on test(a)')
# insert some data here
cursor.execute('select * from test where a glob ?', ['prefix*'])

When the same query is executed in the sqlite3 command line utility, the index 'test_index' is used instead.

sqlite> create table test(a text);
sqlite> create index test_index on test(a);
sqlite> explain query plan select * from test where a glob 'prefix*';
order	from	detail
0	0	TABLE test WITH INDEX test_index

The query in this example is not parametrized as parameters can't be filled in when using the sqlite3 command line utility. This is just to show that the schema and the query allow the index to be used with certain pattern strings.

[0]: http://www.sqlite.org/c3ref/funclist.html
[1]: http://www.sqlite.org/optoverview.html#like_opt

Michael
History
Date User Action Args
2010-07-19 12:08:06feuermurmelsetrecipients: + feuermurmel
2010-07-19 12:08:06feuermurmelsetmessageid: <1279541286.68.0.824716490463.issue9303@psf.upfronthosting.co.za>
2010-07-19 12:08:04feuermurmellinkissue9303 messages
2010-07-19 12:08:03feuermurmelcreate