summaryrefslogtreecommitdiff
path: root/plan.go
blob: 89606d6ea7bb3fbcf7fe9669446d1631fba6f388 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
package main

const testPlan = `
[
  {
    "Plan": {
      "Node Type": "Limit",
      "Startup Cost": 60970.08,
      "Total Cost": 60970.11,
      "Plan Rows": 10,
      "Plan Width": 468,
      "Actual Startup Time": 1941.751,
      "Actual Total Time": 1941.780,
      "Actual Rows": 10,
      "Actual Loops": 1,
      "Output": ["a.id", "(COALESCE(a.display_name, a.alert_name))", "a.external_alert_id", "a.venue_code", "altt.code", "altt.name", "altst.name", "a.stop_type", "a.deploy_mode", "a.estimated_cost", "(sum(s.total_alerts))", "(sum(s.total_followed))", "(sum(s.total_overridden))", "(sum(s.total_ignored))", "(sum(s.total_not_seen))", "(sum(s.total_unknown))", "(percenttotal((sum(s.total_followed)), (sum(s.total_alerts))))", "(percenttotal((sum(s.total_overridden)), (sum(s.total_alerts))))", "(percenttotal((sum(s.total_ignored)), (sum(s.total_alerts))))", "(percenttotal((sum(s.total_not_seen)), (sum(s.total_alerts))))", "(percenttotal((sum(s.total_unknown)), (sum(s.total_alerts))))", "(((sum(s.total_alerts)) * a.estimated_cost))"],
      "Shared Hit Blocks": 260587,
      "Shared Read Blocks": 0,
      "Shared Dirtied Blocks": 0,
      "Shared Written Blocks": 0,
      "Local Hit Blocks": 0,
      "Local Read Blocks": 0,
      "Local Dirtied Blocks": 0,
      "Local Written Blocks": 0,
      "Temp Read Blocks": 0,
      "Temp Written Blocks": 0,
      "I/O Read Time": 0.000,
      "I/O Write Time": 0.000,
      "Plans": [
        {
          "Node Type": "Sort",
          "Parent Relationship": "Outer",
          "Startup Cost": 60970.08,
          "Total Cost": 60977.40,
          "Plan Rows": 2927,
          "Plan Width": 468,
          "Actual Startup Time": 1941.747,
          "Actual Total Time": 1941.757,
          "Actual Rows": 10,
          "Actual Loops": 1,
          "Output": ["a.id", "(COALESCE(a.display_name, a.alert_name))", "a.external_alert_id", "a.venue_code", "altt.code", "altt.name", "altst.name", "a.stop_type", "a.deploy_mode", "a.estimated_cost", "(sum(s.total_alerts))", "(sum(s.total_followed))", "(sum(s.total_overridden))", "(sum(s.total_ignored))", "(sum(s.total_not_seen))", "(sum(s.total_unknown))", "(percenttotal((sum(s.total_followed)), (sum(s.total_alerts))))", "(percenttotal((sum(s.total_overridden)), (sum(s.total_alerts))))", "(percenttotal((sum(s.total_ignored)), (sum(s.total_alerts))))", "(percenttotal((sum(s.total_not_seen)), (sum(s.total_alerts))))", "(percenttotal((sum(s.total_unknown)), (sum(s.total_alerts))))", "(((sum(s.total_alerts)) * a.estimated_cost))"],
          "Sort Key": ["(sum(s.total_alerts))"],
          "Sort Method": "top-N heapsort",
          "Sort Space Used": 27,
          "Sort Space Type": "Memory",
          "Shared Hit Blocks": 260587,
          "Shared Read Blocks": 0,
          "Shared Dirtied Blocks": 0,
          "Shared Written Blocks": 0,
          "Local Hit Blocks": 0,
          "Local Read Blocks": 0,
          "Local Dirtied Blocks": 0,
          "Local Written Blocks": 0,
          "Temp Read Blocks": 0,
          "Temp Written Blocks": 0,
          "I/O Read Time": 0.000,
          "I/O Write Time": 0.000,
          "Plans": [
            {
              "Node Type": "Nested Loop",
              "Parent Relationship": "Outer",
              "Join Type": "Left",
              "Startup Cost": 37552.36,
              "Total Cost": 60906.83,
              "Plan Rows": 2927,
              "Plan Width": 468,
              "Actual Startup Time": 522.250,
              "Actual Total Time": 1865.979,
              "Actual Rows": 32352,
              "Actual Loops": 1,
              "Output": ["a.id", "COALESCE(a.display_name, a.alert_name)", "a.external_alert_id", "a.venue_code", "altt.code", "altt.name", "altst.name", "a.stop_type", "a.deploy_mode", "a.estimated_cost", "(sum(s.total_alerts))", "(sum(s.total_followed))", "(sum(s.total_overridden))", "(sum(s.total_ignored))", "(sum(s.total_not_seen))", "(sum(s.total_unknown))", "percenttotal((sum(s.total_followed)), (sum(s.total_alerts)))", "percenttotal((sum(s.total_overridden)), (sum(s.total_alerts)))", "percenttotal((sum(s.total_ignored)), (sum(s.total_alerts)))", "percenttotal((sum(s.total_not_seen)), (sum(s.total_alerts)))", "percenttotal((sum(s.total_unknown)), (sum(s.total_alerts)))", "((sum(s.total_alerts)) * a.estimated_cost)"],
              "Shared Hit Blocks": 260587,
              "Shared Read Blocks": 0,
              "Shared Dirtied Blocks": 0,
              "Shared Written Blocks": 0,
              "Local Hit Blocks": 0,
              "Local Read Blocks": 0,
              "Local Dirtied Blocks": 0,
              "Local Written Blocks": 0,
              "Temp Read Blocks": 0,
              "Temp Written Blocks": 0,
              "I/O Read Time": 0.000,
              "I/O Write Time": 0.000,
              "Plans": [
                {
                  "Node Type": "Nested Loop",
                  "Parent Relationship": "Outer",
                  "Join Type": "Left",
                  "Startup Cost": 37552.22,
                  "Total Cost": 56750.41,
                  "Plan Rows": 2927,
                  "Plan Width": 461,
                  "Actual Startup Time": 522.141,
                  "Actual Total Time": 1161.187,
                  "Actual Rows": 32352,
                  "Actual Loops": 1,
                  "Output": ["(sum(s.total_alerts))", "(sum(s.total_followed))", "(sum(s.total_overridden))", "(sum(s.total_ignored))", "(sum(s.total_not_seen))", "(sum(s.total_unknown))", "a.id", "a.display_name", "a.alert_name", "a.external_alert_id", "a.venue_code", "a.stop_type", "a.deploy_mode", "a.estimated_cost", "a.subtype_id", "altt.code", "altt.name"],
                  "Shared Hit Blocks": 197115,
                  "Shared Read Blocks": 0,
                  "Shared Dirtied Blocks": 0,
                  "Shared Written Blocks": 0,
                  "Local Hit Blocks": 0,
                  "Local Read Blocks": 0,
                  "Local Dirtied Blocks": 0,
                  "Local Written Blocks": 0,
                  "Temp Read Blocks": 0,
                  "Temp Written Blocks": 0,
                  "I/O Read Time": 0.000,
                  "I/O Write Time": 0.000,
                  "Plans": [
                    {
                      "Node Type": "Nested Loop",
                      "Parent Relationship": "Outer",
                      "Join Type": "Inner",
                      "Startup Cost": 37552.07,
                      "Total Cost": 56230.56,
                      "Plan Rows": 2927,
                      "Plan Width": 405,
                      "Actual Startup Time": 522.131,
                      "Actual Total Time": 918.895,
                      "Actual Rows": 32352,
                      "Actual Loops": 1,
                      "Output": ["(sum(s.total_alerts))", "(sum(s.total_followed))", "(sum(s.total_overridden))", "(sum(s.total_ignored))", "(sum(s.total_not_seen))", "(sum(s.total_unknown))", "a.id", "a.display_name", "a.alert_name", "a.external_alert_id", "a.venue_code", "a.stop_type", "a.deploy_mode", "a.estimated_cost", "a.type_id", "a.subtype_id"],
                      "Shared Hit Blocks": 132411,
                      "Shared Read Blocks": 0,
                      "Shared Dirtied Blocks": 0,
                      "Shared Written Blocks": 0,
                      "Local Hit Blocks": 0,
                      "Local Read Blocks": 0,
                      "Local Dirtied Blocks": 0,
                      "Local Written Blocks": 0,
                      "Temp Read Blocks": 0,
                      "Temp Written Blocks": 0,
                      "I/O Read Time": 0.000,
                      "I/O Write Time": 0.000,
                      "Plans": [
                        {
                          "Node Type": "Aggregate",
                          "Strategy": "Hashed",
                          "Parent Relationship": "Outer",
                          "Startup Cost": 37551.64,
                          "Total Cost": 37624.82,
                          "Plan Rows": 2927,
                          "Plan Width": 56,
                          "Actual Startup Time": 522.107,
                          "Actual Total Time": 587.536,
                          "Actual Rows": 32352,
                          "Actual Loops": 1,
                          "Output": ["s.alert_id", "sum(s.total_alerts)", "sum(s.total_followed)", "sum(s.total_overridden)", "sum(s.total_ignored)", "sum(s.total_not_seen)", "sum(s.total_unknown)"],
                          "Group Key": ["s.alert_id"],
                          "Shared Hit Blocks": 2784,
                          "Shared Read Blocks": 0,
                          "Shared Dirtied Blocks": 0,
                          "Shared Written Blocks": 0,
                          "Local Hit Blocks": 0,
                          "Local Read Blocks": 0,
                          "Local Dirtied Blocks": 0,
                          "Local Written Blocks": 0,
                          "Temp Read Blocks": 0,
                          "Temp Written Blocks": 0,
                          "I/O Read Time": 0.000,
                          "I/O Write Time": 0.000,
                          "Plans": [
                            {
                              "Node Type": "Bitmap Heap Scan",
                              "Parent Relationship": "Outer",
                              "Relation Name": "alert_daily_summaries",
                              "Schema": "analytics",
                              "Alias": "s",
                              "Startup Cost": 3265.35,
                              "Total Cost": 35524.50,
                              "Plan Rows": 115837,
                              "Plan Width": 56,
                              "Actual Startup Time": 10.745,
                              "Actual Total Time": 165.318,
                              "Actual Rows": 140451,
                              "Actual Loops": 1,
                              "Output": ["s.id", "s.org_id", "s.alert_id", "s.alert_day", "s.total_alerts", "s.total_followed", "s.total_overridden", "s.total_ignored", "s.total_not_seen", "s.total_unknown", "s.override_comments"],
                              "Recheck Cond": "((s.org_id = 2) AND (s.alert_day >= '2015-10-01 00:00:00'::timestamp without time zone) AND (s.alert_day <= '2015-12-01 00:00:00'::timestamp without time zone))",
                              "Rows Removed by Index Recheck": 0,
                              "Exact Heap Blocks": 2243,
                              "Lossy Heap Blocks": 0,
                              "Shared Hit Blocks": 2784,
                              "Shared Read Blocks": 0,
                              "Shared Dirtied Blocks": 0,
                              "Shared Written Blocks": 0,
                              "Local Hit Blocks": 0,
                              "Local Read Blocks": 0,
                              "Local Dirtied Blocks": 0,
                              "Local Written Blocks": 0,
                              "Temp Read Blocks": 0,
                              "Temp Written Blocks": 0,
                              "I/O Read Time": 0.000,
                              "I/O Write Time": 0.000,
                              "Plans": [
                                {
                                  "Node Type": "Bitmap Index Scan",
                                  "Parent Relationship": "Outer",
                                  "Index Name": "alert_daily_summaries_org_id_alert_day_idx",
                                  "Startup Cost": 0.00,
                                  "Total Cost": 3236.39,
                                  "Plan Rows": 115837,
                                  "Plan Width": 0,
                                  "Actual Startup Time": 10.445,
                                  "Actual Total Time": 10.445,
                                  "Actual Rows": 140451,
                                  "Actual Loops": 1,
                                  "Index Cond": "((s.org_id = 2) AND (s.alert_day >= '2015-10-01 00:00:00'::timestamp without time zone) AND (s.alert_day <= '2015-12-01 00:00:00'::timestamp without time zone))",
                                  "Shared Hit Blocks": 541,
                                  "Shared Read Blocks": 0,
                                  "Shared Dirtied Blocks": 0,
                                  "Shared Written Blocks": 0,
                                  "Local Hit Blocks": 0,
                                  "Local Read Blocks": 0,
                                  "Local Dirtied Blocks": 0,
                                  "Local Written Blocks": 0,
                                  "Temp Read Blocks": 0,
                                  "Temp Written Blocks": 0,
                                  "I/O Read Time": 0.000,
                                  "I/O Write Time": 0.000
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "Node Type": "Index Scan",
                          "Parent Relationship": "Inner",
                          "Scan Direction": "Forward",
                          "Index Name": "alerts_pkey1",
                          "Relation Name": "alerts",
                          "Schema": "analytics",
                          "Alias": "a",
                          "Startup Cost": 0.42,
                          "Total Cost": 6.34,
                          "Plan Rows": 1,
                          "Plan Width": 213,
                          "Actual Startup Time": 0.004,
                          "Actual Total Time": 0.005,
                          "Actual Rows": 1,
                          "Actual Loops": 32352,
                          "Output": ["a.id", "a.org_id", "a.external_alert_id", "a.alert_name", "a.display_name", "a.estimated_cost", "a.description", "a.source", "a.venue_code", "a.action_expected", "a.cancel_expected", "a.responsible_provider_type", "a.status", "a.version", "a.created_by", "a.created_date", "a.modified_by", "a.modified_date", "a.tracking_id", "a.record_date", "a.released_date", "a.released", "a.comments", "a.default_lockout_hours", "a.deploy_mode", "a.stop_type", "a.importance_level", "a.type_id", "a.subtype_id"],
                          "Index Cond": "(a.id = s.alert_id)",
                          "Rows Removed by Index Recheck": 0,
                          "Shared Hit Blocks": 129627,
                          "Shared Read Blocks": 0,
                          "Shared Dirtied Blocks": 0,
                          "Shared Written Blocks": 0,
                          "Local Hit Blocks": 0,
                          "Local Read Blocks": 0,
                          "Local Dirtied Blocks": 0,
                          "Local Written Blocks": 0,
                          "Temp Read Blocks": 0,
                          "Temp Written Blocks": 0,
                          "I/O Read Time": 0.000,
                          "I/O Write Time": 0.000
                        }
                      ]
                    },
                    {
                      "Node Type": "Index Scan",
                      "Parent Relationship": "Inner",
                      "Scan Direction": "Forward",
                      "Index Name": "alert_types_id_org_id_key",
                      "Relation Name": "alert_types",
                      "Schema": "analytics",
                      "Alias": "altt",
                      "Startup Cost": 0.15,
                      "Total Cost": 0.17,
                      "Plan Rows": 1,
                      "Plan Width": 72,
                      "Actual Startup Time": 0.002,
                      "Actual Total Time": 0.003,
                      "Actual Rows": 1,
                      "Actual Loops": 32352,
                      "Output": ["altt.id", "altt.version", "altt.code", "altt.name", "altt.org_id"],
                      "Index Cond": "(a.type_id = altt.id)",
                      "Rows Removed by Index Recheck": 0,
                      "Shared Hit Blocks": 64704,
                      "Shared Read Blocks": 0,
                      "Shared Dirtied Blocks": 0,
                      "Shared Written Blocks": 0,
                      "Local Hit Blocks": 0,
                      "Local Read Blocks": 0,
                      "Local Dirtied Blocks": 0,
                      "Local Written Blocks": 0,
                      "Temp Read Blocks": 0,
                      "Temp Written Blocks": 0,
                      "I/O Read Time": 0.000,
                      "I/O Write Time": 0.000
                    }
                  ]
                },
                {
                  "Node Type": "Index Scan",
                  "Parent Relationship": "Inner",
                  "Scan Direction": "Forward",
                  "Index Name": "alert_subtypes_id_org_id_key",
                  "Relation Name": "alert_subtypes",
                  "Schema": "analytics",
                  "Alias": "altst",
                  "Startup Cost": 0.14,
                  "Total Cost": 0.16,
                  "Plan Rows": 1,
                  "Plan Width": 23,
                  "Actual Startup Time": 0.002,
                  "Actual Total Time": 0.003,
                  "Actual Rows": 1,
                  "Actual Loops": 32352,
                  "Output": ["altst.id", "altst.version", "altst.code", "altst.name", "altst.org_id"],
                  "Index Cond": "(a.subtype_id = altst.id)",
                  "Rows Removed by Index Recheck": 0,
                  "Shared Hit Blocks": 63472,
                  "Shared Read Blocks": 0,
                  "Shared Dirtied Blocks": 0,
                  "Shared Written Blocks": 0,
                  "Local Hit Blocks": 0,
                  "Local Read Blocks": 0,
                  "Local Dirtied Blocks": 0,
                  "Local Written Blocks": 0,
                  "Temp Read Blocks": 0,
                  "Temp Written Blocks": 0,
                  "I/O Read Time": 0.000,
                  "I/O Write Time": 0.000
                }
              ]
            }
          ]
        }
      ]
    },
    "Planning Time": 0.507,
    "Triggers": [
    ],
    "Execution Time": 1953.684
  }
]
`