为什么在 mysql 中使用限制和偏移量时记录丢失?
Why is record missing while using limit and offset in mysql?
假设我有一个 table 产品。我的 table.
中有几千条记录
当我尝试时
offset_val = 0,10,20,30...
Product.where("live" => true).offset(offset_val).limit(10).order("position DESC")
用不同的 offset_val、
执行相同的查询
我returns我一次只有10条直播产品,结果发现少了一些记录
任何约束或情况都会出现这个问题?
Sample Record Set =[0,1,2,3,4,5,6,7,.....,20]
Expected Output
when offset_val = 10 & limit = 10
=> [10,11,12,13,14,15,16,17,18,19]
Actual Output => [10,11,12,13,15,16,17,18,20,21]
只需确保 "live" => true
丢失的记录
假设我有一个 table 产品。我的 table.
中有几千条记录当我尝试时
offset_val = 0,10,20,30...
Product.where("live" => true).offset(offset_val).limit(10).order("position DESC")
用不同的 offset_val、
执行相同的查询我returns我一次只有10条直播产品,结果发现少了一些记录
任何约束或情况都会出现这个问题?
Sample Record Set =[0,1,2,3,4,5,6,7,.....,20]
Expected Output
when offset_val = 10 & limit = 10
=> [10,11,12,13,14,15,16,17,18,19]
Actual Output => [10,11,12,13,15,16,17,18,20,21]
只需确保 "live" => true
丢失的记录