Skip to content

Commit 62ea6c5

Browse files
Corneil du Plessiscorneil
Corneil du Plessis
authored andcommitted
Migrations for indexes on batch tables to improve aggregate view page queries when customer has large number of job executions in history. They experienced queries exceeding 180s.
1 parent 2c573b1 commit 62ea6c5

File tree

14 files changed

+230
-0
lines changed

14 files changed

+230
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.cloud.dataflow.server.db.migration;
17+
18+
import java.util.Arrays;
19+
import java.util.List;
20+
21+
import org.springframework.cloud.dataflow.common.flyway.AbstractMigration;
22+
import org.springframework.cloud.dataflow.common.flyway.SqlCommand;
23+
24+
/**
25+
* Provide indexes to improve aggregate view performance
26+
* @author Corneil du Plessis
27+
*/
28+
public abstract class AbstractCreateBatchIndexesMigration extends AbstractMigration {
29+
protected static final String CREATE_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_INDEX =
30+
"create index BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BATCH_STEP_EXECUTION(JOB_EXECUTION_ID)";
31+
protected static final String CREATE_BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_INDEX =
32+
"create index BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BOOT3_BATCH_STEP_EXECUTION(JOB_EXECUTION_ID)";
33+
protected static final String CREATE_BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_INDEX =
34+
"create index BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on BOOT3_TASK_TASK_BATCH(JOB_EXECUTION_ID)";
35+
protected static final String CREATE_TASK_TASK_BATCH_JOB_EXECUTION_ID_INDEX =
36+
"create index TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on TASK_TASK_BATCH(JOB_EXECUTION_ID)";
37+
protected static final String CREATE_BATCH_JOB_EXECUTION_START_TIME_INDEX =
38+
"create index BATCH_JOB_EXECUTION_START_TIME_IX on BATCH_JOB_EXECUTION(START_TIME)";
39+
protected static final String CREATE_BOOT3_BATCH_JOB_EXECUTION_START_TIME_INDEX =
40+
"create index BOOT3_BATCH_JOB_EXECUTION_START_TIME_IX on BOOT3_BATCH_JOB_EXECUTION(START_TIME)";
41+
42+
public AbstractCreateBatchIndexesMigration() {
43+
super(null);
44+
}
45+
46+
@Override
47+
public List<SqlCommand> getCommands() {
48+
return Arrays.asList(SqlCommand.from(CREATE_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_INDEX),
49+
SqlCommand.from(CREATE_BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_INDEX),
50+
SqlCommand.from(CREATE_BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_INDEX),
51+
SqlCommand.from(CREATE_TASK_TASK_BATCH_JOB_EXECUTION_ID_INDEX),
52+
SqlCommand.from(CREATE_BATCH_JOB_EXECUTION_START_TIME_INDEX),
53+
SqlCommand.from(CREATE_BOOT3_BATCH_JOB_EXECUTION_START_TIME_INDEX));
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.cloud.dataflow.server.db.migration.db2;
17+
18+
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateBatchIndexesMigration;
19+
20+
public class V10__CreateBatchIndexes extends AbstractCreateBatchIndexesMigration {
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.cloud.dataflow.server.db.migration.mariadb;
17+
18+
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateBatchIndexesMigration;
19+
20+
public class V11__CreateBatchIndexes extends AbstractCreateBatchIndexesMigration {
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.cloud.dataflow.server.db.migration.mysql;
17+
18+
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateBatchIndexesMigration;
19+
20+
public class V11__CreateBatchIndexes extends AbstractCreateBatchIndexesMigration {
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.cloud.dataflow.server.db.migration.oracle;
17+
18+
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateBatchIndexesMigration;
19+
20+
public class V11__CreateBatchIndexes extends AbstractCreateBatchIndexesMigration {
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.cloud.dataflow.server.db.migration.postgresql;
17+
18+
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateBatchIndexesMigration;
19+
20+
public class V12__CreateBatchIndexes extends AbstractCreateBatchIndexesMigration {
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.cloud.dataflow.server.db.migration.sqlserver;
17+
18+
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateBatchIndexesMigration;
19+
20+
public class V10__CreateBatchIndexes extends AbstractCreateBatchIndexesMigration {
21+
22+
}

spring-cloud-dataflow-server-core/src/main/resources/org/springframework/cloud/dataflow/server/db/migration/h2/V1__INITIAL_SETUP.sql

+7
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,10 @@ DROP SEQUENCE task_execution_metadata_seq;
345345
CREATE SEQUENCE TASK_EXECUTION_METADATA_SEQ;
346346
ALTER SEQUENCE TASK_EXECUTION_METADATA_SEQ RESTART WITH (NEXT VALUE FOR task_execution_metadata_seq_lc);
347347
DROP SEQUENCE task_execution_metadata_seq_lc;
348+
349+
create index BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
350+
create index BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BOOT3_BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
351+
create index BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on BOOT3_TASK_TASK_BATCH(JOB_EXECUTION_ID);
352+
create index TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on TASK_TASK_BATCH(JOB_EXECUTION_ID);
353+
create index BATCH_JOB_EXECUTION_START_TIME_IX on BATCH_JOB_EXECUTION(START_TIME);
354+
create index BOOT3_BATCH_JOB_EXECUTION_START_TIME_IX on BOOT3_BATCH_JOB_EXECUTION(START_TIME);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
create index BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
2+
create index BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BOOT3_BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
3+
create index BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on BOOT3_TASK_TASK_BATCH(JOB_EXECUTION_ID);
4+
create index TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on TASK_TASK_BATCH(JOB_EXECUTION_ID);
5+
create index BATCH_JOB_EXECUTION_START_TIME_IX on BATCH_JOB_EXECUTION(START_TIME);
6+
create index BOOT3_BATCH_JOB_EXECUTION_START_TIME_IX on BOOT3_BATCH_JOB_EXECUTION(START_TIME);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
create index BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
2+
create index BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BOOT3_BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
3+
create index BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on BOOT3_TASK_TASK_BATCH(JOB_EXECUTION_ID);
4+
create index TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on TASK_TASK_BATCH(JOB_EXECUTION_ID);
5+
create index BATCH_JOB_EXECUTION_START_TIME_IX on BATCH_JOB_EXECUTION(START_TIME);
6+
create index BOOT3_BATCH_JOB_EXECUTION_START_TIME_IX on BOOT3_BATCH_JOB_EXECUTION(START_TIME);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
create index BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
2+
create index BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BOOT3_BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
3+
create index BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on BOOT3_TASK_TASK_BATCH(JOB_EXECUTION_ID);
4+
create index TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on TASK_TASK_BATCH(JOB_EXECUTION_ID);
5+
create index BATCH_JOB_EXECUTION_START_TIME_IX on BATCH_JOB_EXECUTION(START_TIME);
6+
create index BOOT3_BATCH_JOB_EXECUTION_START_TIME_IX on BOOT3_BATCH_JOB_EXECUTION(START_TIME);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
create index BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
2+
create index BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BOOT3_BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
3+
create index BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on BOOT3_TASK_TASK_BATCH(JOB_EXECUTION_ID);
4+
create index TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on TASK_TASK_BATCH(JOB_EXECUTION_ID);
5+
create index BATCH_JOB_EXECUTION_START_TIME_IX on BATCH_JOB_EXECUTION(START_TIME);
6+
create index BOOT3_BATCH_JOB_EXECUTION_START_TIME_IX on BOOT3_BATCH_JOB_EXECUTION(START_TIME);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
create index BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
2+
create index BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BOOT3_BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
3+
create index BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on BOOT3_TASK_TASK_BATCH(JOB_EXECUTION_ID);
4+
create index TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on TASK_TASK_BATCH(JOB_EXECUTION_ID);
5+
create index BATCH_JOB_EXECUTION_START_TIME_IX on BATCH_JOB_EXECUTION(START_TIME);
6+
create index BOOT3_BATCH_JOB_EXECUTION_START_TIME_IX on BOOT3_BATCH_JOB_EXECUTION(START_TIME);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
create index BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
2+
create index BOOT3_BATCH_STEP_EXECUTION_JOB_EXECUTION_ID_IX on BOOT3_BATCH_STEP_EXECUTION(JOB_EXECUTION_ID);
3+
create index BOOT3_TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on BOOT3_TASK_TASK_BATCH(JOB_EXECUTION_ID);
4+
create index TASK_TASK_BATCH_JOB_EXECUTION_ID_IX on TASK_TASK_BATCH(JOB_EXECUTION_ID);
5+
create index BATCH_JOB_EXECUTION_START_TIME_IX on BATCH_JOB_EXECUTION(START_TIME);
6+
create index BOOT3_BATCH_JOB_EXECUTION_START_TIME_IX on BOOT3_BATCH_JOB_EXECUTION(START_TIME);

0 commit comments

Comments
 (0)