选择性获取卡桑德拉比正常获取更快?
我想知道这是否:
$column_family->get('row_key', $columns=array('name1', 'name2'));
比我现在使用的更灵活的获取更快:
$column_family->get('row_key');
方法1当然更难实现,但它会提供更少的负载/带宽/延迟吗?
I'd like to know if this:
$column_family->get('row_key', $columns=array('name1', 'name2'));
Is faster then the more flexible get i now use:
$column_family->get('row_key');
Method 1 is harder to implement of course but will it give less load/bandwidth/delay?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Cassandra 不是 mysql,因此有些事情有所不同也就不足为奇了。 :)
在这种情况下,Cassandra 的稀疏行存储模型意味着对于少量列,全行版本会更快,因为 Cassandra 不需要反序列化和检查其行级列条目。
当然,对于大量的列,反序列化超出您需要的额外工作将再次占主导地位。
底线:担心这一点几乎肯定是不成熟的优化。如果不是,请测试。
Cassandra is not mysql so it will come as no surprise that some things are different there. :)
In this case, Cassandra's sparse-row storage model means that for small numbers of columns the full-row version will be faster because Cassandra doesn't need to deserialize and check its row-level column entries.
Of course for larger numbers of columns the extra work of deserializing more than you need will dominate again.
Bottom line: worrying about this is almost certainly premature optimization. When it's not, test.
第一个更快,特别是当您使用包含大量列的大型表时。
即使您只有名为
name1
和name2
的两列,指定它们的名称也应该避免从 MySQL 端的表结构中提取列名称。所以它应该比使用*
选择器更快。但是,请使用 microtime() 测试您的结果PHP 对抗大型表,你就会明白我在说什么。当然,如果表中有 20 多列,并且想要将它们全部提取出来,那么放置
*
比列出所有这些列名称更容易,但就速度而言,列出列要快一些。检查这个结论的最好方法就是亲自测试一下。
First one is faster, especially if you work with large tables that contain plenty of columns.
Even you have just two columns called
name1
andname2
, specifying their names should avoid extracting column names from table structure on MySQL side. So it should be faster than using*
selector.However, test your results using microtime() in PHP against large tables and you'll see what I'm talking about. Of course, if you have 20+ columns in table and you want to extract them all it's easier to put
*
than listing all those column-names but in terms of speed, listing columns is bit quicker.The best way to check out this conclusion, is to test it by yourself.