[vlc-commits] sql_lite: If query is not a LIKE % search use = .

Francois Cartegnie git at videolan.org
Thu Sep 13 23:04:36 CEST 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Sep 13 22:39:40 2012 +0200| [5152b38091da496023b9edcd419868bbc38234fc] | committer: Francois Cartegnie

sql_lite: If query is not a LIKE % search use = .

Sqlite can't make use of indexes on LIKE queries.
It always results in a full table scan.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5152b38091da496023b9edcd419868bbc38234fc
---

 modules/media_library/sql_search.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/media_library/sql_search.c b/modules/media_library/sql_search.c
index d69d3d1..5a0848b 100644
--- a/modules/media_library/sql_search.c
+++ b/modules/media_library/sql_search.c
@@ -887,7 +887,8 @@ case casestr:                                                                 \
     assert( tree->comp == ML_COMP_HAS || tree->comp == ML_COMP_EQUAL          \
         || tree->comp == ML_COMP_STARTS_WITH                                  \
         || tree->comp == ML_COMP_ENDS_WITH );                                 \
-    *ppsz_where = sql_Printf( p_ml->p_sys->p_sql, "%s LIKE '%s%q%s'", fmt,    \
+    *ppsz_where = sql_Printf( p_ml->p_sys->p_sql, "%s %s '%s%q%s'", fmt,      \
+        (ML_COMP_EQUAL)?"=":"LIKE",                                           \
         tree->comp == ML_COMP_HAS                                             \
         || tree->comp == ML_COMP_STARTS_WITH? "%%" : "",                      \
             tree->value.str,                                                  \



More information about the vlc-commits mailing list