What is the difference between using .exists?, and .present? in Ruby?

后端 未结 6 2057
独厮守ぢ
独厮守ぢ 2020-12-08 09:32

I want to make sure I\'m using them for the correct occasion and want to know of any subtleties. They seem to function the same way, which is to check to see if a object fi

6条回答
  •  甜味超标
    2020-12-08 10:04

    SELECT COUNT(*) would scan the records to get a count.

    SELECT 1 would stop after the first match, so their exec time would be very different.

提交回复
热议问题