Cassandra is a columnar DB
No, it is not. Cassandra is a partitioned row store.
the columns which are not required are not touched and only selected columns are fetched. As we are storing rows, how only selected columns are touched on disk or memory and not the whole row?
So the underlying file itself is read, and the columns named in a query can be pulled back because the column name/value pairs are stored inside the rows. That makes it easy for Cassandra to just parse out whatever you ask for.
how data looks like on disk?
Consider the a table for weather sensor data with the following PRIMARY KEY definition:
PRIMARY KEY ((city, month), recorded_time)
If I select data for a particular partition, I get this:
> SELECT * FROm weather_sensor_data WHERE city='Minneapolis, MN' AND month=202210;
city | month | recorded_time | temp
-----------------+--------+---------------------------------+------
Minneapolis, MN | 202210 | 2022-10-17 11:30:00.000000+0000 | 1
Minneapolis, MN | 202210 | 2022-10-17 11:25:00.000000+0000 | 1
Minneapolis, MN | 202210 | 2022-10-17 11:20:00.000000+0000 | 2
Minneapolis, MN | 202210 | 2022-10-17 11:15:00.000000+0000 | 2
Minneapolis, MN | 202210 | 2022-10-17 11:00:00.000000+0000 | 2
(5 rows)
If I look at this partition in the underlying SSTable file, I see this:
% ./sstabledump ../../data/data/stackoverflow/weather_sensor_data-4b0472504e5611edbce23d839e1d28ce/nb-1-big-Data.db
[
{
"partition" : {
"key" : [ "Minneapolis, MN", "202210" ],
"position" : 193
},
"rows" : [
{
"type" : "row",
"position" : 232,
"clustering" : [ "2022-10-17 11:30:00.000Z" ],
"liveness_info" : { "tstamp" : "2022-10-17T20:17:02.876617Z" },
"cells" : [
{ "name" : "temp", "value" : 1.0 }
]
},
{
"type" : "row",
"position" : 254,
"clustering" : [ "2022-10-17 11:25:00.000Z" ],
"liveness_info" : { "tstamp" : "2022-10-17T20:16:59.438630Z" },
"cells" : [
{ "name" : "temp", "value" : 1.0 }
]
},
{
"type" : "row",
"position" : 276,
"clustering" : [ "2022-10-17 11:20:00.000Z" ],
"liveness_info" : { "tstamp" : "2022-10-17T20:16:51.304506Z" },
"cells" : [
{ "name" : "temp", "value" : 2.0 }
]
},
{
"type" : "row",
"position" : 298,
"clustering" : [ "2022-10-17 11:15:00.000Z" ],
"liveness_info" : { "tstamp" : "2022-10-17T20:16:42.069043Z" },
"cells" : [
{ "name" : "temp", "value" : 2.0 }
]
},
{
"type" : "row",
"position" : 320,
"clustering" : [ "2022-10-17 11:00:00.000Z" ],
"liveness_info" : { "tstamp" : "2022-10-17T20:16:36.085526Z" },
"cells" : [
{ "name" : "temp", "value" : 2.0 }
]
}
]
},