Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb SQLite doesn't use the FTS index for equa...



details:   https://anonhg.NetBSD.org/src/rev/292652b85654
branches:  trunk
changeset: 777489:292652b85654
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Feb 20 18:27:30 2012 +0000

description:
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.

diffstat:

 usr.sbin/makemandb/whatis.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r d91ad68859f6 -r 292652b85654 usr.sbin/makemandb/whatis.c
--- a/usr.sbin/makemandb/whatis.c       Mon Feb 20 18:25:51 2012 +0000
+++ b/usr.sbin/makemandb/whatis.c       Mon Feb 20 18:27:30 2012 +0000
@@ -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 <joerg%NetBSD.org@localhost>
  * 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 @@
 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 @@
                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),



Home | Main Index | Thread Index | Old Index