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:
$colum开发者_开发问答n_family->get('row_key');
Method 1 is harder to implement of course but will it give less load/bandwidth/delay?
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.
First one is faster, especially if you work with large tables that contain plenty of columns.
Even you have just two columns called name1
and name2
, 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.
精彩评论