Skip to content

Improve performance of instrument list #40

@peer35

Description

@peer35

https://database.cosmin.nl/instruments

  • Check server performance (atp)
  • Improve query
    instruments_controller.rb
...
        @instruments, @alphaParams = Instrument.all
                                         .alpha_paginate(params[:letter], {:default_field => '0-9', :include_all => false, :js => false, :bootstrap3 => true}) { |instrument| instrument.name }
        @instruments.sort_by! { |m| m.name.downcase }
...

This queries all instruments in batches of 500 and then filters them. Slow.

views/instruments/index.html.erb

...
          <td><%= instrument.records.count %></td>
...
          <td>
            <% if instrument.records.count == 0 %>
              <%= link_to 'Delete', instrument, method: :delete, data: {confirm: 'Are you sure?'} %>
            <% end %>
          </td>
...

Results in 2 queries per row (although the second one is from cache). Also slow

  • Use jquery datatables with paginated queries.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions