Tuesday, 3 September 2013

Table name length in sqlite affects performance. Why?

Table name length in sqlite affects performance. Why?

I'm noticing that the length of table names affects performance during
creation of those tables. Here is a code example that reproduces the
problem:

#include <stdio.h>
#include <assert.h>
#include "sqlite3.h"
int main() {
int i, sr;
char table_query[1000];
sqlite3* db;
sr = sqlite3_open("test.db", &db);
assert(sr == SQLITE_OK);
sr = sqlite3_exec(db, "PRAGMA synchronous=OFF", NULL, NULL, NULL);
assert(sr == SQLITE_OK);
sr = sqlite3_exec(db, "PRAGMA journal_mode=OFF", NULL, NULL, NULL);
assert(sr == SQLITE_OK);
sr = sqlite3_exec(db, "PRAGMA temp_store=MEMORY", NULL, NULL, NULL);
assert(sr == SQLITE_OK);
sr = sqlite3_exec(db, "BEGIN EXCLUSIVE TRANSACTION;", NULL, NULL, NULL);
assert(sr == SQLITE_OK);
for (i = 0; i < 10000; ++i) {
#ifdef LONG_NAMES
sprintf(table_query, "CREATE TABLE
`TABLE_%d_AKLKEKABCDEFGHIJK4C6F766520416C6C20546865205061696E204177617920496E636C204B796175202620416C626572742052656D69782020434452`
(content);", i);
#else
sprintf(table_query, "CREATE TABLE `TABLE_%d` (content);", i);

No comments:

Post a Comment