@@ -126,10 +126,11 @@ void* indexUpdater(void* arg)
126
126
sleep (cfg.indexUpdateInterval );
127
127
printf (" Alter indexes\n " );
128
128
time_t now = getCurrentTime ();
129
+ time_t limit = cfg.useSystemTime ? now : currTimestamp;
129
130
{
130
131
work txn (con);
131
132
for (int i = 0 ; i < cfg.nIndexes ; i++) {
132
- exec (txn, " alter index idx%d where pk<%lu" , i, cfg. useSystemTime ? now : currTimestamp );
133
+ exec (txn, " alter index idx%d where pk<%lu" , i, limit );
133
134
}
134
135
txn.commit ();
135
136
}
@@ -151,18 +152,6 @@ void initializeDatabase()
151
152
time_t now = getCurrentTime ();
152
153
exec (txn, " drop table if exists t" );
153
154
exec (txn, " create table t (pk bigint, k1 bigint, k2 bigint, k3 bigint, k4 bigint, k5 bigint, k6 bigint, k7 bigint, k8 bigint)" );
154
- if (!cfg.noPK ) {
155
- exec (txn, " create index pk on t(pk)" );
156
- }
157
- for (int i = 0 ; i < cfg.nIndexes ; i++) {
158
- if (cfg.indexUpdateInterval == 0 ) {
159
- exec (txn, " create index idx%d on t(k%d)" , i, i+1 );
160
- } else if (cfg.useSystemTime ) {
161
- exec (txn, " create index idx%d on t(k%d) where pk<%ld" , i, i+1 , now);
162
- } else {
163
- exec (txn, " create index idx%d on t(k%d) where pk<%ld" , i, i+1 , 0 );
164
- }
165
- }
166
155
167
156
if (cfg.initialSize )
168
157
{
@@ -186,9 +175,26 @@ void initializeDatabase()
186
175
txn.prepared (" insert" )(cfg.initialSize )(cfg.initialSize -1 ).exec ();
187
176
currTimestamp = cfg.initialSize ;
188
177
}
189
- txn.exec (" vacuum analyze" );
178
+ }
179
+ if (!cfg.noPK ) {
180
+ exec (txn, " create index pk on t(pk)" );
181
+ }
182
+ for (int i = 0 ; i < cfg.nIndexes ; i++) {
183
+ if (cfg.indexUpdateInterval == 0 ) {
184
+ exec (txn, " create index idx%d on t(k%d)" , i, i+1 );
185
+ } else if (cfg.useSystemTime ) {
186
+ exec (txn, " create index idx%d on t(k%d) where pk<%ld" , i, i+1 , now);
187
+ } else {
188
+ exec (txn, " create index idx%d on t(k%d) where pk<%ld" , i, i+1 , currTimestamp);
189
+ }
190
190
}
191
191
txn.commit ();
192
+ {
193
+ nontransaction txn (con);
194
+ txn.exec (" vacuum analyze" );
195
+ sleep (2 );
196
+ }
197
+ printf (" Database intialized\n " );
192
198
}
193
199
194
200
@@ -260,10 +266,11 @@ int main (int argc, char* argv[])
260
266
for (int i = 0 ; i < cfg.nInserters ; i++) {
261
267
inserters[i].wait ();
262
268
}
269
+ time_t elapsed = getCurrentTime () - start;
270
+
263
271
running = false ;
264
272
bgw.wait ();
265
273
266
- time_t elapsed = getCurrentTime () - start;
267
274
268
275
printf (
269
276
" {\" tps\" :%f, \" index_updates\" :%d, \" max_update_time\" :%ld, \" avg_update_time\" :%f,"
0 commit comments