2
怎样高效遍历联合主键的表?
source link: https://www.v2ex.com/t/915882
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
create table t
(
a int not null,
b varchar(128) not null,
primary key (b, a)
)
t 有千万行吧, 一般怎么样高效遍历这样的表呢?
只能select * from t where b = 'xx' and a > 'yy' limit 1000
?
问题是 column b 区分度大的话, 每次取到的数据可能远小于 1000
上面用 mysql 的方式讨论一般思路, 其实这个 DB 是 SQL server(第一次用 SQL server), 有特殊技巧吗?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK