mysql - Find if there is a line on table : count or first? -


i wish optimizations on sql queries. without doing performance test it, query time-consuming ? sure return same result.

  • !myclass.find(:first, :conditions => c).nil?
  • myclass.count(:conditions => c) > 0
  • myclass.count(:conditions => c, :limit => 1) > 0

regards

you can test own. writing performance test less 15 lines of code. more information:

http://guides.rubyonrails.org/performance_testing.html


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -