From 135560d23ec7688044cfb20b958bd528806eba80 Mon Sep 17 00:00:00 2001 From: David Keeler Date: Wed, 10 May 2017 15:56:55 -0700 Subject: [PATCH] Bug 1363569 - improve SQL queries in sdb_FindObjects* r=franziskus Summary: When sqlite prepares statements, it appears to have an algorithm which is O(n * m), where n is the number of columns in the table and m is the number of columns selected in the query. Since the certificate database has about 115 columns, when "SELECT * FROM ..." is used, it introduces significant overhead. Since sdb_FindObjects only uses the id column of the results of the query, the queries in sdb_FindObjectsInit can be changed to select only the id column rather than all of them. Reviewers: franziskus Reviewed By: franziskus Differential Revision: https://nss-review.dev.mozaws.net/D314 --HG-- extra : rebase_source : ed5bf33591d406b5dc062dc624a7d1bc3f018940 extra : amend_source : aa310794fb10d253f4cd24c98799969e5ff9e98c --- lib/softoken/sdb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/softoken/sdb.c b/lib/softoken/sdb.c index 0e321dd524..8690df34ca 100644 --- a/lib/softoken/sdb.c +++ b/lib/softoken/sdb.c @@ -674,8 +674,8 @@ struct SDBFindStr { sqlite3_stmt *findstmt; }; -static const char FIND_OBJECTS_CMD[] = "SELECT ALL * FROM %s WHERE %s;"; -static const char FIND_OBJECTS_ALL_CMD[] = "SELECT ALL * FROM %s;"; +static const char FIND_OBJECTS_CMD[] = "SELECT ALL id FROM %s WHERE %s;"; +static const char FIND_OBJECTS_ALL_CMD[] = "SELECT ALL id FROM %s;"; CK_RV sdb_FindObjectsInit(SDB *sdb, const CK_ATTRIBUTE *template, CK_ULONG count, SDBFind **find)