Skip to content

Commit 9d81f1d

Browse files
authored
Changes ListClosedWorkflow result ordering for SQL-based visibility stores to be based off of workflow close time (#578)
This PR fixes the following issues: SQL stores were using the Workflow Open Time instead of the Close Time for pagination, which is not aligned with Cassandra and is not the intention. The SQL store pagination logic had a bug where the tie-breaker logic of using run_id for two rows with the same close_time was not implemented properly. The SQL store pagination logic had a bug where it was using the MinStart time instead of the MaxStart time for pagination purposes (to be confirmed as to whether this is truly a bug or not, but it does appear that way) Fixes Makefile so that schema installation for MySQL / Postgres functions properly. Fixes Postgres username / password in postgres development environment. Adds appropriate MySQL/Postgres indexes for querying by close_time
1 parent 7c6df6d commit 9d81f1d

File tree

9 files changed

+102
-50
lines changed

9 files changed

+102
-50
lines changed

Makefile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,20 @@ install-schema-mysql-pre5720: temporal-sql-tool
328328

329329
install-schema-mysql: temporal-sql-tool
330330
@printf $(COLOR) "Install MySQL schema..."
331-
./temporal-sql-tool --ep 127.0.0.1 create --db temporal
332-
./temporal-sql-tool --ep 127.0.0.1 --db temporal setup-schema -v 0.0
333-
./temporal-sql-tool --ep 127.0.0.1 --db temporal update-schema -d ./schema/mysql/v57/temporal/versioned
334-
./temporal-sql-tool --ep 127.0.0.1 create --db temporal_visibility
335-
./temporal-sql-tool --ep 127.0.0.1 --db temporal_visibility setup-schema -v 0.0
336-
./temporal-sql-tool --ep 127.0.0.1 --db temporal_visibility update-schema -d ./schema/mysql/v57/visibility/versioned
331+
./temporal-sql-tool --ep 127.0.0.1 -u root --pw root create --db temporal
332+
./temporal-sql-tool --ep 127.0.0.1 -u root --pw root --db temporal setup-schema -v 0.0
333+
./temporal-sql-tool --ep 127.0.0.1 -u root --pw root --db temporal update-schema -d ./schema/mysql/v57/temporal/versioned
334+
./temporal-sql-tool --ep 127.0.0.1 -u root --pw root create --db temporal_visibility
335+
./temporal-sql-tool --ep 127.0.0.1 -u root --pw root --db temporal_visibility setup-schema -v 0.0
336+
./temporal-sql-tool --ep 127.0.0.1 -u root --pw root --db temporal_visibility update-schema -d ./schema/mysql/v57/visibility/versioned
337337

338338
install-schema-postgres: temporal-sql-tool
339339
@printf $(COLOR) "Install Postgres schema..."
340-
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u postgres -pw temporal --pl postgres create --db temporal
341-
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u postgres -pw temporal --pl postgres --db temporal setup -v 0.0
342-
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u postgres -pw temporal --pl postgres --db temporal update-schema -d ./schema/postgres/temporal/versioned
343-
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u postgres -pw temporal --pl postgres create --db temporal_visibility
344-
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u postgres -pw temporal --pl postgres --db temporal_visibility setup-schema -v 0.0
345-
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u postgres -pw temporal --pl postgres --db temporal_visibility update-schema -d ./schema/postgres/visibility/versioned
340+
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u temporal -pw temporal --pl postgres --db temporal setup -v 0.0
341+
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u temporal -pw temporal --pl postgres --db temporal update-schema -d ./schema/postgres/temporal/versioned
342+
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u temporal -pw temporal --pl postgres create --db temporal_visibility
343+
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u temporal -pw temporal --pl postgres --db temporal_visibility setup-schema -v 0.0
344+
./temporal-sql-tool --ep 127.0.0.1 -p 5432 -u temporal -pw temporal --pl postgres --db temporal_visibility update-schema -d ./schema/postgres/visibility/versioned
346345

347346
install-schema-cdc: temporal-cassandra-tool
348347
@printf $(COLOR) "Set up temporal_active key space..."

common/persistence/sql/sqlVisibilityStore.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (s *sqlVisibilityStore) UpsertWorkflowExecution(request *p.InternalUpsertWo
117117
}
118118

119119
func (s *sqlVisibilityStore) ListOpenWorkflowExecutions(request *p.ListWorkflowExecutionsRequest) (*p.InternalListWorkflowExecutionsResponse, error) {
120-
return s.listWorkflowExecutions("ListOpenWorkflowExecutions", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime,
120+
return s.listWorkflowExecutions("ListOpenWorkflowExecutions", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime, false,
121121
func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error) {
122122
minStartTime := time.Unix(0, request.EarliestStartTime)
123123
return s.db.SelectFromVisibility(&sqlplugin.VisibilityFilter{
@@ -132,7 +132,7 @@ func (s *sqlVisibilityStore) ListOpenWorkflowExecutions(request *p.ListWorkflowE
132132
}
133133

134134
func (s *sqlVisibilityStore) ListClosedWorkflowExecutions(request *p.ListWorkflowExecutionsRequest) (*p.InternalListWorkflowExecutionsResponse, error) {
135-
return s.listWorkflowExecutions("ListClosedWorkflowExecutions", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime,
135+
return s.listWorkflowExecutions("ListClosedWorkflowExecutions", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime, true,
136136
func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error) {
137137
minStartTime := time.Unix(0, request.EarliestStartTime)
138138
return s.db.SelectFromVisibility(&sqlplugin.VisibilityFilter{
@@ -146,7 +146,7 @@ func (s *sqlVisibilityStore) ListClosedWorkflowExecutions(request *p.ListWorkflo
146146
}
147147

148148
func (s *sqlVisibilityStore) ListOpenWorkflowExecutionsByType(request *p.ListWorkflowExecutionsByTypeRequest) (*p.InternalListWorkflowExecutionsResponse, error) {
149-
return s.listWorkflowExecutions("ListOpenWorkflowExecutionsByType", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime,
149+
return s.listWorkflowExecutions("ListOpenWorkflowExecutionsByType", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime, false,
150150
func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error) {
151151
minStartTime := time.Unix(0, request.EarliestStartTime)
152152
return s.db.SelectFromVisibility(&sqlplugin.VisibilityFilter{
@@ -162,7 +162,7 @@ func (s *sqlVisibilityStore) ListOpenWorkflowExecutionsByType(request *p.ListWor
162162
}
163163

164164
func (s *sqlVisibilityStore) ListClosedWorkflowExecutionsByType(request *p.ListWorkflowExecutionsByTypeRequest) (*p.InternalListWorkflowExecutionsResponse, error) {
165-
return s.listWorkflowExecutions("ListClosedWorkflowExecutionsByType", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime,
165+
return s.listWorkflowExecutions("ListClosedWorkflowExecutionsByType", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime, true,
166166
func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error) {
167167
minStartTime := time.Unix(0, request.EarliestStartTime)
168168
return s.db.SelectFromVisibility(&sqlplugin.VisibilityFilter{
@@ -177,7 +177,7 @@ func (s *sqlVisibilityStore) ListClosedWorkflowExecutionsByType(request *p.ListW
177177
}
178178

179179
func (s *sqlVisibilityStore) ListOpenWorkflowExecutionsByWorkflowID(request *p.ListWorkflowExecutionsByWorkflowIDRequest) (*p.InternalListWorkflowExecutionsResponse, error) {
180-
return s.listWorkflowExecutions("ListOpenWorkflowExecutionsByWorkflowID", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime,
180+
return s.listWorkflowExecutions("ListOpenWorkflowExecutionsByWorkflowID", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime, false,
181181
func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error) {
182182
minStartTime := time.Unix(0, request.EarliestStartTime)
183183
return s.db.SelectFromVisibility(&sqlplugin.VisibilityFilter{
@@ -193,7 +193,7 @@ func (s *sqlVisibilityStore) ListOpenWorkflowExecutionsByWorkflowID(request *p.L
193193
}
194194

195195
func (s *sqlVisibilityStore) ListClosedWorkflowExecutionsByWorkflowID(request *p.ListWorkflowExecutionsByWorkflowIDRequest) (*p.InternalListWorkflowExecutionsResponse, error) {
196-
return s.listWorkflowExecutions("ListClosedWorkflowExecutionsByWorkflowID", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime,
196+
return s.listWorkflowExecutions("ListClosedWorkflowExecutionsByWorkflowID", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime, true,
197197
func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error) {
198198
minStartTime := time.Unix(0, request.EarliestStartTime)
199199
return s.db.SelectFromVisibility(&sqlplugin.VisibilityFilter{
@@ -208,7 +208,7 @@ func (s *sqlVisibilityStore) ListClosedWorkflowExecutionsByWorkflowID(request *p
208208
}
209209

210210
func (s *sqlVisibilityStore) ListClosedWorkflowExecutionsByStatus(request *p.ListClosedWorkflowExecutionsByStatusRequest) (*p.InternalListWorkflowExecutionsResponse, error) {
211-
return s.listWorkflowExecutions("ListClosedWorkflowExecutionsByStatus", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime,
211+
return s.listWorkflowExecutions("ListClosedWorkflowExecutionsByStatus", request.NextPageToken, request.EarliestStartTime, request.LatestStartTime, true,
212212
func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error) {
213213
minStartTime := time.Unix(0, request.EarliestStartTime)
214214
return s.db.SelectFromVisibility(&sqlplugin.VisibilityFilter{
@@ -287,7 +287,13 @@ func (s *sqlVisibilityStore) rowToInfo(row *sqlplugin.VisibilityRow) *p.Visibili
287287
return info
288288
}
289289

290-
func (s *sqlVisibilityStore) listWorkflowExecutions(opName string, pageToken []byte, earliestTime int64, latestTime int64, selectOp func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error)) (*p.InternalListWorkflowExecutionsResponse, error) {
290+
func (s *sqlVisibilityStore) listWorkflowExecutions(
291+
opName string,
292+
pageToken []byte,
293+
earliestTime int64,
294+
latestTime int64,
295+
closeQuery bool,
296+
selectOp func(readLevel *visibilityPageToken) ([]sqlplugin.VisibilityRow, error)) (*p.InternalListWorkflowExecutionsResponse, error) {
291297
var readLevel *visibilityPageToken
292298
var err error
293299
if len(pageToken) > 0 {
@@ -312,10 +318,14 @@ func (s *sqlVisibilityStore) listWorkflowExecutions(opName string, pageToken []b
312318
}
313319
var nextPageToken []byte
314320
lastRow := rows[len(rows)-1]
315-
lastStartTime := lastRow.StartTime
316-
if lastStartTime.Sub(time.Unix(0, earliestTime)).Nanoseconds() > 0 {
321+
lastTime := lastRow.StartTime
322+
if closeQuery {
323+
lastTime = *lastRow.CloseTime
324+
}
325+
326+
if lastTime.Sub(time.Unix(0, earliestTime)).Nanoseconds() > 0 {
317327
nextPageToken, err = s.serializePageToken(&visibilityPageToken{
318-
Time: lastStartTime,
328+
Time: lastTime,
319329
RunID: lastRow.RunID,
320330
})
321331
if err != nil {

common/persistence/sql/sqlplugin/mysql/visibility.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@ const (
4545
templateConditions = ` AND namespace_id = ?
4646
AND start_time >= ?
4747
AND start_time <= ?
48-
AND (run_id > ? OR start_time < ?)
48+
AND ((run_id > ? and start_time = ?) OR (start_time < ?))
4949
ORDER BY start_time DESC, run_id
50-
LIMIT ?`
50+
LIMIT ?`
51+
52+
templateConditionsClosedWorkflows = ` AND namespace_id = ?
53+
AND close_time >= ?
54+
AND close_time <= ?
55+
AND ((run_id > ? and close_time = ?) OR (close_time < ?))
56+
ORDER BY close_time DESC, run_id
57+
LIMIT ?`
5158

5259
templateOpenFieldNames = `workflow_id, run_id, start_time, execution_time, workflow_type_name, status, memo, encoding`
5360
templateOpenSelect = `SELECT ` + templateOpenFieldNames + ` FROM executions_visibility WHERE status = 1 `
@@ -57,17 +64,17 @@ const (
5764

5865
templateGetOpenWorkflowExecutions = templateOpenSelect + templateConditions
5966

60-
templateGetClosedWorkflowExecutions = templateClosedSelect + templateConditions
67+
templateGetClosedWorkflowExecutions = templateClosedSelect + templateConditionsClosedWorkflows
6168

6269
templateGetOpenWorkflowExecutionsByType = templateOpenSelect + `AND workflow_type_name = ?` + templateConditions
6370

64-
templateGetClosedWorkflowExecutionsByType = templateClosedSelect + `AND workflow_type_name = ?` + templateConditions
71+
templateGetClosedWorkflowExecutionsByType = templateClosedSelect + `AND workflow_type_name = ?` + templateConditionsClosedWorkflows
6572

6673
templateGetOpenWorkflowExecutionsByID = templateOpenSelect + `AND workflow_id = ?` + templateConditions
6774

68-
templateGetClosedWorkflowExecutionsByID = templateClosedSelect + `AND workflow_id = ?` + templateConditions
75+
templateGetClosedWorkflowExecutionsByID = templateClosedSelect + `AND workflow_id = ?` + templateConditionsClosedWorkflows
6976

70-
templateGetClosedWorkflowExecutionsByStatus = templateClosedSelect + `AND status = ?` + templateConditions
77+
templateGetClosedWorkflowExecutionsByStatus = templateClosedSelect + `AND status = ?` + templateConditionsClosedWorkflows
7178

7279
templateGetClosedWorkflowExecution = `SELECT workflow_id, run_id, start_time, execution_time, memo, encoding, close_time, workflow_type_name, status, history_length
7380
FROM executions_visibility
@@ -153,7 +160,8 @@ func (mdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl
153160
mdb.converter.ToMySQLDateTime(*filter.MinStartTime),
154161
mdb.converter.ToMySQLDateTime(*filter.MaxStartTime),
155162
*filter.RunID,
156-
*filter.MinStartTime,
163+
*filter.MaxStartTime,
164+
*filter.MaxStartTime,
157165
*filter.PageSize)
158166
case filter.MinStartTime != nil && filter.WorkflowTypeName != nil:
159167
qry := templateGetOpenWorkflowExecutionsByType
@@ -168,6 +176,7 @@ func (mdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl
168176
mdb.converter.ToMySQLDateTime(*filter.MaxStartTime),
169177
*filter.RunID,
170178
*filter.MaxStartTime,
179+
*filter.MaxStartTime,
171180
*filter.PageSize)
172181
case filter.MinStartTime != nil && filter.Status != 0 && filter.Status != 1: // 0 is UNSPECIFIED, 1 is RUNNING
173182
err = mdb.conn.Select(&rows,
@@ -178,6 +187,7 @@ func (mdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl
178187
mdb.converter.ToMySQLDateTime(*filter.MaxStartTime),
179188
*filter.RunID,
180189
mdb.converter.ToMySQLDateTime(*filter.MaxStartTime),
190+
mdb.converter.ToMySQLDateTime(*filter.MaxStartTime),
181191
*filter.PageSize)
182192
case filter.MinStartTime != nil:
183193
qry := templateGetOpenWorkflowExecutions
@@ -191,6 +201,7 @@ func (mdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl
191201
mdb.converter.ToMySQLDateTime(*filter.MaxStartTime),
192202
*filter.RunID,
193203
mdb.converter.ToMySQLDateTime(*filter.MaxStartTime),
204+
mdb.converter.ToMySQLDateTime(*filter.MaxStartTime),
194205
*filter.PageSize)
195206
default:
196207
return nil, fmt.Errorf("invalid query filter")

common/persistence/sql/sqlplugin/postgres/visibility.go

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,31 @@ const (
5757
templateConditions1 = ` AND namespace_id = $1
5858
AND start_time >= $2
5959
AND start_time <= $3
60-
AND (run_id > $4 OR start_time < $5)
60+
AND ((run_id > $4 and start_time = $5) OR (start_time < $6))
6161
ORDER BY start_time DESC, run_id
62-
LIMIT $6`
62+
LIMIT $7`
6363

6464
templateConditions2 = ` AND namespace_id = $2
6565
AND start_time >= $3
6666
AND start_time <= $4
67-
AND (run_id > $5 OR start_time < $6)
67+
AND ((run_id > $5 and start_time = $6) OR (start_time < $7))
6868
ORDER BY start_time DESC, run_id
69+
LIMIT $8`
70+
71+
templateConditionsClosedWorkflow1 = ` AND namespace_id = $1
72+
AND close_time >= $2
73+
AND close_time <= $3
74+
AND ((run_id > $4 and close_time = $5) OR (close_time < $6))
75+
ORDER BY close_time DESC, run_id
6976
LIMIT $7`
7077

78+
templateConditionsClosedWorkflow2 = ` AND namespace_id = $2
79+
AND close_time >= $3
80+
AND close_time <= $4
81+
AND ((run_id > $5 and close_time = $6) OR (close_time < $7))
82+
ORDER BY close_time DESC, run_id
83+
LIMIT $8`
84+
7185
templateOpenFieldNames = `workflow_id, run_id, start_time, execution_time, workflow_type_name, status, memo, encoding`
7286
templateOpenSelect = `SELECT ` + templateOpenFieldNames + ` FROM executions_visibility WHERE status = 1 `
7387

@@ -76,17 +90,17 @@ const (
7690

7791
templateGetOpenWorkflowExecutions = templateOpenSelect + templateConditions1
7892

79-
templateGetClosedWorkflowExecutions = templateClosedSelect + templateConditions1
93+
templateGetClosedWorkflowExecutions = templateClosedSelect + templateConditionsClosedWorkflow1
8094

8195
templateGetOpenWorkflowExecutionsByType = templateOpenSelect + `AND workflow_type_name = $1` + templateConditions2
8296

83-
templateGetClosedWorkflowExecutionsByType = templateClosedSelect + `AND workflow_type_name = $1` + templateConditions2
97+
templateGetClosedWorkflowExecutionsByType = templateClosedSelect + `AND workflow_type_name = $1` + templateConditionsClosedWorkflow2
8498

8599
templateGetOpenWorkflowExecutionsByID = templateOpenSelect + `AND workflow_id = $1` + templateConditions2
86100

87-
templateGetClosedWorkflowExecutionsByID = templateClosedSelect + `AND workflow_id = $1` + templateConditions2
101+
templateGetClosedWorkflowExecutionsByID = templateClosedSelect + `AND workflow_id = $1` + templateConditionsClosedWorkflow2
88102

89-
templateGetClosedWorkflowExecutionsByStatus = templateClosedSelect + `AND status = $1` + templateConditions2
103+
templateGetClosedWorkflowExecutionsByStatus = templateClosedSelect + `AND status = $1` + templateConditionsClosedWorkflow2
90104

91105
templateGetClosedWorkflowExecution = `SELECT workflow_id, run_id, start_time, execution_time, memo, encoding, close_time, workflow_type_name, status, history_length
92106
FROM executions_visibility
@@ -172,7 +186,8 @@ func (pdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl
172186
pdb.converter.ToPostgresDateTime(*filter.MinStartTime),
173187
pdb.converter.ToPostgresDateTime(*filter.MaxStartTime),
174188
*filter.RunID,
175-
*filter.MinStartTime,
189+
*filter.MaxStartTime,
190+
*filter.MaxStartTime,
176191
*filter.PageSize)
177192
case filter.MinStartTime != nil && filter.WorkflowTypeName != nil:
178193
qry := templateGetOpenWorkflowExecutionsByType
@@ -187,6 +202,7 @@ func (pdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl
187202
pdb.converter.ToPostgresDateTime(*filter.MaxStartTime),
188203
*filter.RunID,
189204
*filter.MaxStartTime,
205+
*filter.MaxStartTime,
190206
*filter.PageSize)
191207
case filter.MinStartTime != nil && filter.Status != 0 && filter.Status != 1: // 0 is UNSPECIFIED, 1 is RUNNING
192208
err = pdb.conn.Select(&rows,
@@ -197,6 +213,7 @@ func (pdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl
197213
pdb.converter.ToPostgresDateTime(*filter.MaxStartTime),
198214
*filter.RunID,
199215
pdb.converter.ToPostgresDateTime(*filter.MaxStartTime),
216+
pdb.converter.ToPostgresDateTime(*filter.MaxStartTime),
200217
*filter.PageSize)
201218
case filter.MinStartTime != nil:
202219
qry := templateGetOpenWorkflowExecutions
@@ -212,6 +229,7 @@ func (pdb *db) SelectFromVisibility(filter *sqlplugin.VisibilityFilter) ([]sqlpl
212229
maxSt,
213230
*filter.RunID,
214231
maxSt,
232+
maxSt,
215233
*filter.PageSize)
216234
default:
217235
return nil, fmt.Errorf("invalid query filter")

config/development_postgres.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ persistence:
99
databaseName: "temporal"
1010
connectAddr: "127.0.0.1:5432"
1111
connectProtocol: "tcp"
12-
user: "postgres"
12+
user: "temporal"
1313
password: "temporal"
1414
maxConns: 20
1515
maxIdleConns: 20
@@ -20,7 +20,7 @@ persistence:
2020
databaseName: "temporal_visibility"
2121
connectAddr: "127.0.0.1:5432"
2222
connectProtocol: "tcp"
23-
user: "postgres"
23+
user: "temporal"
2424
password: "temporal"
2525
maxConns: 2
2626
maxIdleConns: 2
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE TABLE executions_visibility (
2-
namespace_id CHAR(64) NOT NULL,
2+
namespace_id CHAR(64) NOT NULL,
33
run_id CHAR(64) NOT NULL,
44
start_time DATETIME(6) NOT NULL,
55
execution_time DATETIME(6) NOT NULL,
@@ -10,11 +10,14 @@ CREATE TABLE executions_visibility (
1010
history_length BIGINT,
1111
memo BLOB,
1212
encoding VARCHAR(64) NOT NULL,
13-
task_queue VARCHAR(255) DEFAULT '' NOT NULL,
13+
task_queue VARCHAR(255) DEFAULT '' NOT NULL,
1414

1515
PRIMARY KEY (namespace_id, run_id)
1616
);
1717

1818
CREATE INDEX by_type_start_time ON executions_visibility (namespace_id, workflow_type_name, status, start_time DESC, run_id);
1919
CREATE INDEX by_workflow_id_start_time ON executions_visibility (namespace_id, workflow_id, status, start_time DESC, run_id);
20-
CREATE INDEX by_status_by_close_time ON executions_visibility (namespace_id, status, start_time DESC, run_id);
20+
CREATE INDEX by_status_by_start_time ON executions_visibility (namespace_id, status, start_time DESC, run_id);
21+
CREATE INDEX by_type_close_time ON executions_visibility (namespace_id, workflow_type_name, status, close_time DESC, run_id);
22+
CREATE INDEX by_workflow_id_close_time ON executions_visibility (namespace_id, workflow_id, status, close_time DESC, run_id);
23+
CREATE INDEX by_status_by_close_time ON executions_visibility (namespace_id, status, close_time DESC, run_id);

0 commit comments

Comments
 (0)