Skip to content

Commit 36bb1cc

Browse files
knizhnikkelvich
authored andcommitted
Add initial size to insbench
1 parent 1c399de commit 36bb1cc

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

src/backend/commands/indexcmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ AlterIndex(Oid indexRelationId, IndexStmt *stmt)
315315

316316
/* Open the target index relation */
317317
/* indexRelation = index_open(indexRelationId, RowExclusiveLock); */
318-
//indexRelation = index_open(indexRelationId, ShareUpdateExclusiveLock);
319-
indexRelation = index_open(indexRelationId, AccessShareLock);
318+
indexRelation = index_open(indexRelationId, ShareUpdateExclusiveLock);
319+
/* indexRelation = index_open(indexRelationId, AccessShareLock); */
320320
namespaceId = RelationGetNamespace(indexRelation);
321321

322322
pg_index = heap_open(IndexRelationId, RowExclusiveLock);

src/backend/tcop/utility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ ProcessUtilitySlow(Node *parsetree,
12441244
* eventually be needed here, so the lockmode calculation
12451245
* needs to match what DefineIndex() does.
12461246
*/
1247-
lockmode = stmt->is_alter ? AccessShareLock : stmt->concurrent ? ShareUpdateExclusiveLock
1247+
lockmode = stmt->is_alter || stmt->concurrent ? ShareUpdateExclusiveLock
12481248
: ShareLock;
12491249
relid =
12501250
RangeVarGetRelidExtended(stmt->relation, lockmode,

src/bin/insbench/insbench.cpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ struct config
4141
int nIndexes;
4242
int nIterations;
4343
int transactionSize;
44+
int initialSize;
4445
bool useSystemTime;
4546
bool noPK;
4647
string connection;
4748

4849
config() {
50+
initialSize = 1000000;
4951
indexUpdateInterval = 0;
5052
nInserters = 1;
5153
nIndexes = 8;
@@ -142,8 +144,8 @@ void* indexUpdater(void* arg)
142144

143145
void initializeDatabase()
144146
{
145-
connection conn(cfg.connection);
146-
work txn(conn);
147+
connection con(cfg.connection);
148+
work txn(con);
147149
time_t now = getCurrentTime();
148150
exec(txn, "drop table if exists t");
149151
exec(txn, "create table t (pk bigint, k1 bigint, k2 bigint, k3 bigint, k4 bigint, k5 bigint, k6 bigint, k7 bigint, k8 bigint)");
@@ -159,6 +161,31 @@ void initializeDatabase()
159161
exec(txn, "create index idx%d on t(k%d) where pk<%ld", i, i+1, 0);
160162
}
161163
}
164+
165+
if (cfg.initialSize)
166+
{
167+
if (cfg.useSystemTime)
168+
{
169+
#if PQXX_VERSION_MAJOR >= 4
170+
con.prepare("insert", "insert into t values ($1,$2,$3,$4,$5,$6,$7,$8,$9)");
171+
#else
172+
con.prepare("insert", "insert into t values ($1,$2,$3,$4,$5,$6,$7,$8,$9)")("bigint")("bigint")("bigint")("bigint")("bigint")("bigint")("bigint")("bigint")("bigint");
173+
#endif
174+
} else {
175+
con.prepare("insert", "insert into t (select generate_series($1::integer,$2::integer),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000))");
176+
}
177+
if (cfg.useSystemTime)
178+
{
179+
for (int i = 0; i < cfg.initialSize; i++)
180+
{
181+
txn.prepared("insert")(getCurrentTime())(random())(random())(random())(random())(random())(random())(random())(random()).exec();
182+
}
183+
} else {
184+
txn.prepared("insert")(cfg.initialSize)(cfg.initialSize-1).exec();
185+
currTimestamp = cfg.initialSize;
186+
}
187+
txn.exec("vacuum analyze");
188+
}
162189
txn.commit();
163190
}
164191

@@ -185,9 +212,12 @@ int main (int argc, char* argv[])
185212
case 'n':
186213
cfg.nIterations = atoi(argv[++i]);
187214
continue;
188-
case 'i':
215+
case 'x':
189216
cfg.nIndexes = atoi(argv[++i]);
190217
continue;
218+
case 'i':
219+
cfg.initialSize = atoi(argv[++i]);
220+
continue;
191221
case 'c':
192222
cfg.connection = string(argv[++i]);
193223
continue;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy