I'm working on a rails app that has a whole bunch of before filters in the users_controller which look up user's stateful roles provided by Acts as State Machine. They look something like this:
class UsersController < ApplicationController
before_filter :not_logged_in_required, :only => [:new, :create]
before_filter :find_user_or_current_user, :only => [:edit, :update]
before_filter :find_user, :only => [:suspend, :unsuspend, :destroy, :purge]
before_filter :admin_required, :only => [:suspend, :unsuspend, :destroy, :purge]
before_filter :check_administrator_role, :only [:index, :suspend, :destroy, :purge]
With all of this checking of states for each action controlled by the UsersController, performance is becoming an issue, with SQL queries to the Users Column taking upwards of 5ms on my machine.
I'm only assuming all of these filters play a part in the dragging performance, and I'm wondering how to best refactor these to improve the reading from the database.