Skip to content

Commit

Permalink
Combine SQLite indexes for more efficient use
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Trabant committed Mar 11, 2017
1 parent cebc1db commit 043a29b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2017.069: 2.2
- Combine SQLite indexes for more efficient use.

2017.068:
- Add -sqlitebusyto option to allow changes to the SQLite busy
timeout value.
Expand Down
31 changes: 5 additions & 26 deletions src/mseedindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
*
* Written by Chad Trabant, IRIS Data Management Center.
*
* modified 2017.068
* modified 2017.069
***************************************************************************/

#define _GNU_SOURCE
Expand All @@ -106,7 +106,7 @@

#include "md5.h"

#define VERSION "2.2dev"
#define VERSION "2.2"
#define PACKAGE "mseedindex"

static flag verbose = 0;
Expand Down Expand Up @@ -1113,9 +1113,10 @@ SyncSQLite (void)
return -1;
}

/* Create index for (network,station,location,channel,quality) */
/* Create index for (network,station,location,channel,starttime,endtime) */
rv = SQLiteExec (dbconn, NULL, NULL, &errmsg,
"CREATE INDEX IF NOT EXISTS %s_nslcq_idx ON %s (network,station,location,channel,quality)",
"CREATE INDEX IF NOT EXISTS %s_nslcse_idx ON %s "
"(network,station,location,channel,starttime,endtime)",
table, table);
if (rv != SQLITE_OK)
{
Expand All @@ -1135,28 +1136,6 @@ SyncSQLite (void)
return -1;
}

/* Create index for (starttime) */
rv = SQLiteExec (dbconn, NULL, NULL, &errmsg,
"CREATE INDEX IF NOT EXISTS %s_starttime_idx ON %s (starttime)",
table, table);
if (rv != SQLITE_OK)
{
ms_log (2, "SQLite CREATE INDEX failed: %s\n", (errmsg) ? errmsg : "");
sqlite3_free (errmsg);
return -1;
}

/* Create index for (endtime) */
rv = SQLiteExec (dbconn, NULL, NULL, &errmsg,
"CREATE INDEX IF NOT EXISTS %s_endtime_idx ON %s (endtime)",
table, table);
if (rv != SQLITE_OK)
{
ms_log (2, "SQLite CREATE INDEX failed: %s\n", (errmsg) ? errmsg : "");
sqlite3_free (errmsg);
return -1;
}

/* Create index for (updated) */
rv = SQLiteExec (dbconn, NULL, NULL, &errmsg,
"CREATE INDEX IF NOT EXISTS %s_updated_idx ON %s (updated)",
Expand Down

0 comments on commit 043a29b

Please sign in to comment.