SQLite and SELECT WHERE local_relpath LIKE
From: Philip Martin <philip.martin_at_wandisco.com>
Date: Fri, 29 Oct 2010 08:58:02 +0100
We have started using queries of the form
SELECT ... WHERE ... AND local_relpath LIKE ...
and I was curious about the performance of LIKE. So I tried a large
$ sqlite3 wcx.db "select count(*) from nodes"
and a LIKE query:
$ time sqlite3 wcx.db "select count(*) from nodes where wc_id = 1 and local_relpath = 'zig1/zag27' or local_relpath like 'zig1/zag27/%' escape '%'"
real 0m0.398s
Using escape adds a bit to the time, as does the double check on
A suggested optimisation is
$ time sqlite3 wcx.db "select count(*) from nodes where wc_id = 1 and local_relpath >= 'zig1/zag27' and local_relpath < 'zig1/zag28'"
real 0m0.005s
I checked using "select *" and the two queries return the same data.
Can we reliably calculate the "next string" for a given UTF-8 string?
-- PhilipReceived on 2010-10-29 09:58:45 CEST |
This is an archived mail posted to the Subversion Dev mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.