Module Name:    src
Committed By:   joerg
Date:           Mon Feb 20 18:27:30 UTC 2012

Modified Files:
        src/usr.sbin/makemandb: whatis.c

Log Message:
SQLite doesn't use the FTS index for equal ops, so force it to do a FTS
search first. Drops run time by a factor of 6 for "whatis man".
Found by Abhinav Upadhyay.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/whatis.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makemandb/whatis.c
diff -u src/usr.sbin/makemandb/whatis.c:1.2 src/usr.sbin/makemandb/whatis.c:1.3
--- src/usr.sbin/makemandb/whatis.c:1.2	Tue Feb  7 19:17:16 2012
+++ src/usr.sbin/makemandb/whatis.c	Mon Feb 20 18:27:30 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: whatis.c,v 1.2 2012/02/07 19:17:16 joerg Exp $	*/
+/*	$NetBSD: whatis.c,v 1.3 2012/02/20 18:27:30 joerg Exp $	*/
 /*-
  * Copyright (c) 2012 Joerg Sonnenberger <jo...@netbsd.org>
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: whatis.c,v 1.2 2012/02/07 19:17:16 joerg Exp $");
+__RCSID("$NetBSD: whatis.c,v 1.3 2012/02/20 18:27:30 joerg Exp $");
 
 #include <err.h>
 #include <stdio.h>
@@ -49,7 +49,7 @@ static int
 whatis(sqlite3 *db, const char *cmd)
 {
 	static const char sqlstr[] = "SELECT name, section, name_desc"
-				     " FROM mandb WHERE name=?"
+				     " FROM mandb WHERE name MATCH ? AND name=?"
 				     " ORDER BY section, name";
 	sqlite3_stmt *stmt = NULL;
 	int retval;
@@ -58,6 +58,8 @@ whatis(sqlite3 *db, const char *cmd)
 		errx(EXIT_FAILURE, "Unable to query database");
 	if (sqlite3_bind_text(stmt, 1, cmd, -1, NULL) != SQLITE_OK)
 		errx(EXIT_FAILURE, "Unable to query database");
+	if (sqlite3_bind_text(stmt, 2, cmd, -1, NULL) != SQLITE_OK)
+		errx(EXIT_FAILURE, "Unable to query database");
 	retval = 1;
 	while (sqlite3_step(stmt) == SQLITE_ROW) {
 		printf("%s(%s) - %s\n", sqlite3_column_text(stmt, 0),

Reply via email to