Performance impact in using camelCase in Cassandra columns

拜拜、爱过 提交于 2019-12-23 04:48:43

问题


I know, Cassandra generally converts all the column names into lowercase.

Is there a performance impact in using the camelCase in column names in Cassandra?

I used the double quote in columns and I am able to store the column names in the camelCase, like below

CREATE TABLE test (
  Foo int PRIMARY KEY,
  "Bar" int
);

Will there be a performance impact in storing the column name with the double quotes?


回答1:


I don't believe there's an impact. I would say that the case-insensitive nature of CQL only serves the purpose of simplifying queries, as you can see from this answer: https://stackoverflow.com/a/28447941/824644

Also, it seems that there was a motivation for this behavior due to the preference of lower camel case in Java (which is the language in which Cassandra is written in). See the discussion in this GitHub issue: https://github.com/reuzel/CqlSharp/issues/28




回答2:


Space wise no. Performance wise, no. (Well, even assuming you have to wire the double quotes, if you use prepared statements, you will send once, so it is negligible)

On Cassandra 3, the names are only written once on the Header of the sstables (Reference: http://thelastpickle.com/blog/2016/03/04/introductiont-to-the-apache-cassandra-3-storage-engine.html).

It gets pretty weird on having to always provide the double quotes (CQLSH for example), so I normally don't do it. Also, older cluster that started with Thrift and migrated to CQL have a lot of that. So, to avoid confusion regarding the origins (but there are better ways of verifying this) it is good to keep the quotes away.




回答3:


There's no impact performance wise. CQL downcases unquoted identifiers. I understand it may cause trouble for developers, as it may be easy to handle camel or mixed cases but if you're trying to access the table through APIs then you may have defined a class that maps to that table. I don't see any overhead where you would need to change the table name and etc when accessing through the API.

Moreover, when you've a bigger team of developers it is seen as a good data modeling practice to name columns as lowercase or use underscores instead of camel case. That is done as default by cassandra. If you really need the casing then just use double quotes.



来源:https://stackoverflow.com/questions/48519880/performance-impact-in-using-camelcase-in-cassandra-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!