-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. From Joerg. (Diff imported from NetBSD CVS repo)
- Loading branch information
1 parent
57ca0e7
commit 9f32431
Showing
1 changed file
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
* 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), | ||
|