{% extends "../../xhr.html" %}
{% block content %}
<div class="indexes">
    <h4>Index suggestion</h4>
        {% if len(indexes) > 0 %}
          <ul>
                {% for clause, index in indexes.items() %}
                <li>
                <h5>Possible indexes for attributes present in <b>{{clause}}</b>:</h5>
                <ul>
                {% for am, quals in index.items() %}
                <li>
                  <h6>With access method <em>{{ am }}</em></h6>
                  <ul>
                  {% for qual in quals %}
                  <li>
                    <dl>
                      <dt>Attribute</dt>
                      <dd>{{ qual['relname'] }}.{{ qual['attname']}}</dd>
                      <dt>Data distribution</dt>
                      {% if qual['n_distinct'] >= 0 %}
                      <dd>approximately <b>{{ qual['n_distinct'] }}</b> distinct values</dd>
                      {%else %}
                      <dd>approximately <b>{{ abs(qual['n_distinct']) * 100 }} %</b> distinct values</dd>
                      {% end %}
                      <dt>
                    </dl>
                  </li>
                  {% end %}
                  </ul>
                </li>
                {% end %}
                </ul>
                </li>
                {% end %}
          </ul>
        {% else %}
            No suitable index to suggest.
        {% end %}
    </div>
</div>
{% end %}
