@@ -156,13 +156,19 @@ void* writer(void* arg)
156
156
void initializeDatabase ()
157
157
{
158
158
connectionconn (cfg.connection );
159
- int accountsPerShard = (cfg.nAccounts + cfg.nShards -1 )/cfg.nShards ;
160
- for (int i =0 ; i < cfg.nShards ; i++)
161
- {
159
+ if (cfg.nShards ==0 ) {
162
160
worktxn (conn);
163
- exec (txn," alter table t_fdw%i add check (u between %d and %d)" , i+1 , accountsPerShard*i, accountsPerShard*(i+1 )-1 );
164
- exec (txn," insert into t_fdw%i (select generate_series(%d,%d), %d)" , i+1 , accountsPerShard*i, accountsPerShard*(i+1 )-1 ,0 );
161
+ exec (txn," insert into t (select generate_series(1,%d), 0)" , cfg.nAccounts );
165
162
txn.commit ();
163
+ }else {
164
+ int accountsPerShard = (cfg.nAccounts + cfg.nShards -1 )/cfg.nShards ;
165
+ for (int i =0 ; i < cfg.nShards ; i++)
166
+ {
167
+ worktxn (conn);
168
+ exec (txn," alter table t_fdw%i add check (u between %d and %d)" , i+1 , accountsPerShard*i, accountsPerShard*(i+1 )-1 );
169
+ exec (txn," insert into t_fdw%i (select generate_series(%d,%d), %d)" , i+1 , accountsPerShard*i, accountsPerShard*(i+1 )-1 ,0 );
170
+ txn.commit ();
171
+ }
166
172
}
167
173
}
168
174