Hi @ all
I have a little performance issue with Authlogic - I dealed with them over days... and i can't figure out!
The Problem is: I use the standard-Authlogic installation with following code in the application_controler to get the current_user (and to persits the session):
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.user
end
Now the performance issue: Authlogic generates on ever request to the site a SQL-statement to persist the session and gets back the current_user. But the SQL Statement is like:
**User Load (0.3ms)** SELECT * FROM `users` WHERE (`users`.`id` = '1') LIMIT 1
this SELECT *
is my problem!
1. I don't want a current_user, that has all the attributes from the User-Model (there are a lot of stuff which I don't use by every request - for example hobbies or prefered_music etc. (a lot of data))
2. A SELECT * is slower than a SELECT a,b,c...
I want something like:
**User Load (0.1ms)** SELECT id, name, profilphoto_file_name FROM `users` WHERE (`users`.`id` = '1') LIMIT 1
But UserSession.find(:select => "id,...")
didn't work because .find
is a method from Authlogic (session/persistence.rb line 36) and not from ActiveRecord!
Now I don't know where Authlogic forms the SQL-Statement???
(my second idea is: split the User-Model into: user and user_details - so the SELECT * From users is not soo underperformant, but I would prefer the Authlogic hack.)
Thanks you!