Advertisement
Guest User

Untitled

a guest
Jul 28th, 2011
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.00 KB | None | 0 0
  1. --- db_bench_sqlite3.cc.orig    2011-07-28 23:46:04.000000000 +0400
  2. +++ db_bench_sqlite3.cc 2011-07-29 05:27:58.000000000 +0400
  3. @@ -74,7 +74,7 @@
  4.  static bool FLAGS_transaction = true;
  5.  
  6.  // If true, we enable Write-Ahead Logging
  7. -static bool FLAGS_WAL_enabled = false;
  8. +static bool FLAGS_WAL_enabled = true;
  9.  
  10.  inline
  11.  static void ExecErrorCheck(int status, char *err_msg) {
  12. @@ -454,10 +454,10 @@
  13.  
  14.      // Change locking mode to exclusive and create tables/index for database
  15.      std::string locking_stmt = "PRAGMA locking_mode = EXCLUSIVE";
  16. +    std::string wal_stmt = "PRAGMA wal_autocheckpoint = 4096";
  17.      std::string create_stmt =
  18. -          "CREATE TABLE test (key blob, value blob, PRIMARY KEY(key))";
  19. -    std::string index_stmt = "CREATE INDEX keyindex ON test (key)";
  20. -    std::string stmt_array[] = { locking_stmt, create_stmt, index_stmt };
  21. +          "CREATE TABLE test (key INTEGER PRIMARY KEY, value blob)";
  22. +    std::string stmt_array[] = { locking_stmt, wal_stmt, create_stmt };
  23.      int stmt_array_length = sizeof(stmt_array) / sizeof(std::string);
  24.      for (int i = 0; i < stmt_array_length; i++) {
  25.        status = sqlite3_exec(db_, stmt_array[i].c_str(), NULL, NULL, &err_msg);
  26. @@ -494,7 +494,7 @@
  27.      std::string end_trans_str = "END TRANSACTION;";
  28.  
  29.      // Check for synchronous flag in options
  30. -    std::string sync_stmt = (write_sync) ? "PRAGMA synchronous = FULL" :
  31. +    std::string sync_stmt = (write_sync) ? "PRAGMA synchronous = NORMAL" :
  32.                                             "PRAGMA synchronous = OFF";
  33.      status = sqlite3_exec(db_, sync_stmt.c_str(), NULL, NULL, &err_msg);
  34.      ExecErrorCheck(status, err_msg);
  35. @@ -527,18 +527,16 @@
  36.          // Create values for key-value pair
  37.          const int k = (order == SEQUENTIAL) ? i + j :
  38.                        (rand_.Next() % num_entries);
  39. -        char key[100];
  40. -        snprintf(key, sizeof(key), "%016d", k);
  41.  
  42.          // Bind KV values into replace_stmt
  43. -        status = sqlite3_bind_blob(replace_stmt, 1, key, 16, SQLITE_STATIC);
  44. +        status = sqlite3_bind_int(replace_stmt, 1, k);
  45.          ErrorCheck(status);
  46.          status = sqlite3_bind_blob(replace_stmt, 2, value,
  47.                                     value_size, SQLITE_STATIC);
  48.          ErrorCheck(status);
  49.  
  50.          // Execute replace_stmt
  51. -        bytes_ += value_size + strlen(key);
  52. +        bytes_ += value_size + sizeof(k);
  53.          status = sqlite3_step(replace_stmt);
  54.          StepErrorCheck(status);
  55.  
  56. @@ -599,12 +597,10 @@
  57.        // Create and execute SQL statements
  58.        for (int j = 0; j < entries_per_batch; j++) {
  59.          // Create key value
  60. -        char key[100];
  61.          int k = (order == SEQUENTIAL) ? i + j : (rand_.Next() % reads_);
  62. -        snprintf(key, sizeof(key), "%016d", k);
  63.  
  64.          // Bind key value into read_stmt
  65. -        status = sqlite3_bind_blob(read_stmt, 1, key, 16, SQLITE_STATIC);
  66. +        status = sqlite3_bind_int(read_stmt, 1, k);
  67.          ErrorCheck(status);
  68.  
  69.          // Execute read statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement