|
1 | 1 | var m = require("mithril"); |
2 | 2 | var BigOFactor = require("./BigOFactor"); |
3 | 3 |
|
4 | | -var Table = function(name, rows, accessType, key) { |
| 4 | +var Table = function(name, rows, accessType, key, possibleKeys, keyLength, ref, filtered) { |
5 | 5 | this.name = name; |
6 | 6 | this.rows = rows; |
7 | 7 | this.newRows = rows; |
8 | 8 | this.key = key; |
| 9 | + this.possibleKeys = possibleKeys; |
| 10 | + this.keyLength = keyLength; |
| 11 | + this.ref = ref; |
| 12 | + this.filtered = filtered; |
9 | 13 | var t = this; |
10 | 14 | this.setNewRows = function() { |
11 | 15 | if (this.value == "") { |
@@ -50,29 +54,25 @@ var TablesScalability = function(tables) { |
50 | 54 | var factor = 1; |
51 | 55 | return m("div", |
52 | 56 | m("h4", "Estimation"), |
53 | | - m("table.pure-table", [ |
54 | | - m("thead", |
55 | | - m("tr", [ |
56 | | - m("th", "Table"), |
57 | | - m("th", "Row count"), |
58 | | - m("th", "Estimated row count"), |
59 | | - ]) |
60 | | - ), // thead |
61 | | - m("tbody", |
62 | | - vnode.state.tables.map(function(o) { |
63 | | - var disabled = false; |
64 | | - if (o.bigO) { |
65 | | - factor *= o.bigO.factor(o.newRows); |
66 | | - } else { |
67 | | - disabled = true; |
68 | | - } |
69 | | - return m("tr", |
70 | | - m("td", o.name), |
71 | | - m("td", o.rows), |
72 | | - m("td", m("input", {value: o.newRows, oninput: o.setNewRows, disabled: disabled})) |
73 | | - ) |
74 | | - }) |
75 | | - ) // tbody |
| 57 | + m("table", [ |
| 58 | + m("tr", [ |
| 59 | + m("th", "Table"), |
| 60 | + m("th", "Row count"), |
| 61 | + m("th", "Estimated row count or scale factor"), |
| 62 | + ]), |
| 63 | + vnode.state.tables.map(function(o) { |
| 64 | + var disabled = false; |
| 65 | + if (o.bigO) { |
| 66 | + factor *= o.bigO.factor(o.newRows); |
| 67 | + } else { |
| 68 | + disabled = true; |
| 69 | + } |
| 70 | + return m("tr", |
| 71 | + m("td", o.name), |
| 72 | + m("td", o.rows), |
| 73 | + m("td", m("input", {value: o.newRows, oninput: o.setNewRows, disabled: disabled})) |
| 74 | + ) |
| 75 | + }) |
76 | 76 | ]), |
77 | 77 | m("p", |
78 | 78 | "Latency scale factor: ", |
@@ -144,35 +144,47 @@ var Analysis = function(explain) { |
144 | 144 | this.explain.tables.map(function(o) { |
145 | 145 | var rows = o.rows_examined_per_scan || o.rows; |
146 | 146 | vnode.state.tables.push( |
147 | | - new Table(o.table_name, rows, o.access_type, o.key) |
| 147 | + new Table( |
| 148 | + o.table_name, |
| 149 | + o.rows_examined_per_scan, |
| 150 | + o.access_type, |
| 151 | + o.key, |
| 152 | + o.possible_keys, |
| 153 | + o.key_length, |
| 154 | + o.ref, |
| 155 | + o.filtered) |
148 | 156 | ) |
149 | 157 | }) |
150 | 158 | vnode.state.tablesScalability = new TablesScalability(vnode.state.tables); |
151 | 159 | vnode.state.commentary = new Comments(vnode.state.tables); |
152 | 160 | }.bind(this); |
153 | 161 | this.view = function(vnode) { |
154 | 162 | return m("div", [ |
155 | | - m("table.pure-table", [ |
156 | | - m("thead", |
157 | | - m("tr", [ |
158 | | - m("th", "Table"), |
159 | | - m("th", "Access type"), |
160 | | - m("th", "Index"), |
161 | | - m("th", "Rows examined per scan"), |
162 | | - m("th", "Scalability"), |
163 | | - ]) |
164 | | - ), // thead |
165 | | - m("tbody", |
166 | | - vnode.state.tables.map(function(o) { |
167 | | - return m("tr", |
168 | | - m("td", o.name), |
169 | | - m("td", o.accessType), |
170 | | - m("td", o.key || "N/A"), |
171 | | - m("td", o.rows), |
172 | | - m("td", "O(" + o.scalability + ")") |
173 | | - ) |
174 | | - }) |
175 | | - ) // tbody |
| 163 | + m("table", [ |
| 164 | + m("tr", [ |
| 165 | + m("th", "Table"), |
| 166 | + m("th", "Access type"), |
| 167 | + m("th", "Possible indexes"), |
| 168 | + m("th", "Index"), |
| 169 | + m("th", "Index key length"), |
| 170 | + m("th", "Ref"), |
| 171 | + m("th", "Rows examined per scan"), |
| 172 | + m("th", "Filtered"), |
| 173 | + m("th", "Scalability"), |
| 174 | + ]), |
| 175 | + vnode.state.tables.map(function(o) { |
| 176 | + return m("tr", |
| 177 | + m("td", o.name), |
| 178 | + m("td", o.accessType), |
| 179 | + m("td", o.possibleKeys || "N/A"), |
| 180 | + m("td", o.key || "N/A"), |
| 181 | + m("td", o.keyLength || "N/A"), |
| 182 | + m("td", (o.ref || []).join(", ")), |
| 183 | + m("td", o.rows), |
| 184 | + m("td", o.filtered), |
| 185 | + m("td", "O(" + o.scalability + ")") |
| 186 | + ) |
| 187 | + }) |
176 | 188 | ]), |
177 | 189 | m(vnode.state.tablesScalability), |
178 | 190 | m(vnode.state.commentary) |
|
0 commit comments