我们有一个内存网格平台,它从数据库引导数据,现在我们有 8 个节点,我们必须在 8 个节点之间平均分配数据。所以我们使用 % 运算符如下
select * from LargeTable where id % 8 = 1
select * from LargeTable where id % 8 = 2
select * from LargeTable where id % 8 = 3
select * from LargeTable where id % 8 = 4
select * from LargeTable where id % 8 = 5
select * from LargeTable where id % 8 = 6
select * from LargeTable where id % 8 = 7
select * from LargeTable where id % 8 = 8
但是我们观察到的是表扫描查询使用全表扫描而不是使用索引,并且我们有数百万条记录的数据,有什么办法可以强制它使用索引来提高性能或任何其他建议表示赞赏。