Skip to content
This repository
Browse code

Support for postgres plans

  • Loading branch information...
commit 79c0a9bb1ed6a36535676501291a8e4691eef069 1 parent 11c77b0
Bill Kayser bkayser authored
23 ui/controllers/newrelic_controller.rb
@@ -83,19 +83,16 @@ def explain_sql
83 83 explanations = @segment.explain_sql
84 84 if explanations
85 85 @explanation = explanations.first
86   -
87   - @row_headers = [
88   - nil,
89   - "Select Type",
90   - "Table",
91   - "Type",
92   - "Possible Keys",
93   - "Key",
94   - "Key Length",
95   - "Ref",
96   - "Rows",
97   - "Extra"
98   - ];
  86 + if !@explanation.blank?
  87 + first_row = @explanation.first
  88 + # Show the standard headers if it looks like a mysql explain plan
  89 + # Otherwise show blank headers
  90 + if first_row.length < NewRelic::MYSQL_EXPLAIN_COLUMNS.length
  91 + @row_headers = nil
  92 + else
  93 + @row_headers = NewRelic::MYSQL_EXPLAIN_COLUMNS
  94 + end
  95 + end
99 96 end
100 97 end
101 98
15 ui/views/newrelic/_explain_plans.rhtml
... ... @@ -1,4 +1,5 @@
1   -<% @row_headers.length.times do |r| %>
  1 +<% if @row_headers %>
  2 + <% @row_headers.length.times do |r| %>
2 3 <% if @row_headers[r] %>
3 4 <tr>
4 5 <th align=right nowrap>
@@ -11,4 +12,16 @@
11 12 <% end %>
12 13 </tr>
13 14 <% end %>
  15 + <% end %>
  16 +<% else %>
  17 + <tr>
  18 + <th align=right>Plan</th>
  19 + <td><p class="plan">
  20 + <% @explanation.each do |row| -%>
  21 + <% row.each do |col| -%>
  22 +<%= h(col) %>
  23 + <% end -%>
  24 + <% end -%>
  25 + </p></td>
  26 + </tr>
14 27 <% end %>
8 ui/views/newrelic/stylesheets/style.css
@@ -28,7 +28,7 @@ body{
28 28 width:76em;
29 29 }
30 30 #content{
31   - width: 984;
  31 + width: 984px;
32 32 margin: 10px auto;
33 33 text-align:left;
34 34 }
@@ -234,6 +234,12 @@ div.flash.notice
234 234 overflow: auto;
235 235 }
236 236
  237 +.plan
  238 +{
  239 + font-family: monospace;
  240 + font-size: 0.8em;
  241 + white-space: pre;
  242 +}
237 243 #page_nav
238 244 {
239 245 height: 42px;

0 comments on commit 79c0a9b

Please sign in to comment.
Something went wrong with that request. Please try again.