Search code examples
phpdatabasenosqlcassandraphpcassa

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?


Solution

  • 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.