'.find'를 어디에 사용하고 어디에 'where'를 사용해야하는지 혼란 스럽습니다. 쿼리 실행 중 성능 차이가 있습니까 ??.find 또는 활성 레코드 쿼리의 조건
예 : 아래 .find 사용하는 기존의 쿼리 변환 된 :
FileOrFolder.find_by_fullpath(completePath, :select=>"id")
은 ->
FileOrFolder.where(fullpath: completePath).select(:id).first
Component.find(:first, :conditions=>["cluster_id = ? AND name = ?", cluster_id, key])
->
Component.where(cluster_id: cluster_id, name: key).first
성능의 차이를 볼 관계 (http://stackoverflow.com/questions/9574659/rails-where-vs-find) – MrYoshiji
@MrYoshiji ... 나는이 게시물을 통해 갔다 .... 아니 어디 쿼리 성능 오른쪽에 대해 이야기 ... ..pls 내가 틀렸다면 나를 바로 잡는다. – Vinay
당신은 콘솔'Component.where (id : 1) .first'와'Component.find (1)'에서 테스트함으로써 직접 할 수있다. 동일 검색어이기 때문에 똑같은 시간이 걸립니다. – MrYoshiji