使用 gocql
或者 gocqlx
,没有获取第n页的示例:
CREATE TABLE IF NOT EXISTS users (
id BIGINT, -- unique using distributed synchronous counter (redis-like), since Scylla doesn't support RETURNING on counter
email TEXT, -- to enforce uniqueness
PRIMARY KEY(email)
);
CREATE INDEX IF NOT EXISTS ON users(id);
查询功能:
func QueryRows(cql string) (res []M.SX) { // M.SX is map[string]interface{}
q := Database.Query(cql) // database is the connection to scylla
defer q.Release()
res = []M.SX{}
iter := q.Iter()
for {
row := M.SX{}
if !iter.MapScan(row) {
break
}
res = append(res, row)
}
return
}
有没有简单但性能好(没有 ALLOW FILTERING
)取第n页(按顺序) email
或者 id
)?
SELECT * FROM users WHERE id > 44 LIMIT 10 ALLOW FILTERING;
-- eg. 44 is last id of current page
1条答案
按热度按时间1l5u6lss1#
嗨,你尝试过基于令牌的分页吗?
“锡拉卜”公司/gocqlx的例子
https://github.com/scylladb/gocqlx/blob/master/example_test.go#l168