rails - pluck vs map
访问量: 382
pluck: pick 1 attribute from array
map: re-implement your function
my_array.map(&:id)
my_array.pluck(:id)
the same. pluck faster than map
XXTransaction Pluck (0.3ms) SELECT "xx_transactions"."id" FROM "xx_transactions" WHERE "xx_transactions"."id" = $1 [["id", 18068574]] XXTransaction Load (0.5ms) SELECT "xx_transactions".* FROM "xx_transactions" WHERE "xx_transactions"."id" = $1 [["id", 18068574]]