Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9219f15

Browse files
committed
ALTER INDEX ... WHERE
1 parent934b406 commit9219f15

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

‎contrib/pg_dtm/tests/dtmbench.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct config
7070
nWriters =10;
7171
nIterations =1000;
7272
nAccounts =1000;
73-
isolationLevel ="repeatable read";//"read committed";
73+
isolationLevel ="read committed";
7474
}
7575
};
7676

‎src/backend/commands/indexcmds.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ AlterIndex(Oid indexRelationId, IndexStmt *stmt)
368368
SPI_cursor_fetch(portal, true,1);
369369
if (!SPI_processed) {
370370
break;
371-
}
371+
}
372372
tuple=SPI_tuptable->vals[0];
373373
tupleid=&tuple->t_data->t_ctid;
374374
ExecStoreTuple(tuple,slot,InvalidBuffer, false);

‎src/bin/insbench/insbench.cpp‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ void* indexUpdater(void* arg)
126126
sleep(cfg.indexUpdateInterval);
127127
printf("Alter indexes\n");
128128
time_t now =getCurrentTime();
129+
time_t limit = cfg.useSystemTime ? now : currTimestamp;
129130
{
130131
worktxn(con);
131132
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);
133134
}
134135
txn.commit();
135136
}
@@ -151,18 +152,6 @@ void initializeDatabase()
151152
time_t now =getCurrentTime();
152153
exec(txn,"drop table if exists t");
153154
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-
}elseif (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-
}
166155

167156
if (cfg.initialSize)
168157
{
@@ -186,9 +175,26 @@ void initializeDatabase()
186175
txn.prepared("insert")(cfg.initialSize)(cfg.initialSize-1).exec();
187176
currTimestamp = cfg.initialSize;
188177
}
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+
}elseif (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+
}
190190
}
191191
txn.commit();
192+
{
193+
nontransactiontxn(con);
194+
txn.exec("vacuum analyze");
195+
sleep(2);
196+
}
197+
printf("Database intialized\n");
192198
}
193199

194200

@@ -260,10 +266,11 @@ int main (int argc, char* argv[])
260266
for (int i =0; i < cfg.nInserters; i++) {
261267
inserters[i].wait();
262268
}
269+
time_t elapsed =getCurrentTime() - start;
270+
263271
running =false;
264272
bgw.wait();
265273

266-
time_t elapsed =getCurrentTime() - start;
267274

268275
printf(
269276
"{\"tps\":%f,\"index_updates\":%d,\"max_update_time\":%ld,\"avg_update_time\":%f,"

‎src/bin/insbench/run.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
echo Insert with 1 index
2+
./insbench -c"dbname=postgres host=localhost port=5432 sslmode=disable" -x 0
3+
echo Insert with 9 indexex
4+
./insbench -c"dbname=postgres host=localhost port=5432 sslmode=disable" -x 8
5+
echo Insert with 9 partial indexes
6+
./insbench -c"dbname=postgres host=localhost port=5432 sslmode=disable" -x 8 -u 1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp