Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selective get in cassandra faster than normal get?

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?

like image 269
Writecoder Avatar asked May 06 '11 17:05

Writecoder


2 Answers

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.

like image 60
jbellis Avatar answered Sep 30 '22 14:09

jbellis


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.

like image 22
Wh1T3h4Ck5 Avatar answered Sep 30 '22 14:09

Wh1T3h4Ck5