0 Remembe..." />

Changing Rails Query to Pure SQL?

Analogously to find_by_sql you can use count_by_sql : User. Count_by_sql("SELECT COUNT(*) FROM users you WHERE u. Email =?", params:email) > 0 Remember also to use the syntax "...? ...", var here to protect against SQL injection However, I doubt that you can achieve a significant performance improvement by that.

Test it. If it's not faster, stay with the ActiveRecord version or try to find a more nifty solution to your problem Edit: If you just want to test whether an given email is already contained in the table you could also test the performance of User. Find_by_email(params:email).

Present?

Analogously to find_by_sql you can use count_by_sql: User. Count_by_sql("SELECT COUNT(*) FROM users you WHERE u. Email =?", params:email) > 0 Remember also to use the syntax "...? ...", var here to protect against SQL injection.

However, I doubt that you can achieve a significant performance improvement by that. Test it. If it's not faster, stay with the ActiveRecord version or try to find a more nifty solution to your problem.

Edit: If you just want to test whether an given email is already contained in the table you could also test the performance of User. Find_by_email(params:email). Present?

1 +1 - @Spashlin - poor performance probably means your User. Email column needs an index. – nonnb Aug 29 '10 at 15:21 1 Alternately, you could use User.

Exists?(:email => params:email) if you're just looking to see if the user is already present. This takes care of escaping automatically. – Beerlington Aug 29 '10 at 16:18 Oh, that's even better!

– duddle Aug 29 '10 at 19:28.

...", var here to protect against SQL injection. However, I doubt that you can achieve a significant performance improvement by that. If it's not faster, stay with the ActiveRecord version or try to find a more nifty solution to your problem.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions