cassandra主键。如果整数vs varchar的性能影响 [英] cassandra primary key. performance implications if integer vs varchar

查看:299
本文介绍了cassandra主键。如果整数vs varchar的性能影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Cassandra中,如果主键是varchar而不是int或bigint,会有性能损失吗?我有id作为主键。我不会做任何数学操作。我使用id只是插入,retrive比较。我想将其更改为字符串为我的一个要求。

In Cassandra , Will there be performance penalty if primary key is varchar instead of int or bigint ? I have id as primary key. I wont do any math operation on that. I use id just to insert,retrive compare. I want to change that to string for one of my requirements. Will the perforamnce go down ?

推荐答案

没有任何明显的区别。主键查找在令牌上完成,即密钥的散列。因此,比较结果与键的数据类型或大小无关。

There won't be any noticeable difference. Primary key lookups are done on the token i.e. the hash of the key. The comparisons are therefore independent of the data type or size of the key.

较长的键需要稍长的时间才能进行哈希。并且对原始键有一些内部比较,但我非常怀疑任何这是重要的,所以请继续使用任何类型,最适合您的数据。

Longer keys will take slightly longer to hash. And there are some internal comparisons on the raw key but I very much doubt any of this is significant so go ahead and use whatever type is best for your data.

这篇关于cassandra主键。如果整数vs varchar的性能影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆