Database Reference
In-Depth Information
Partial selection of user-defined types
In some situations, we might only be interested in what school alice went to, but not her
year of graduation. In this case, we would like to be able to perform a query that returns
precisely the information we're interested in, without wasting network bandwidth on irrel-
evant data. Happily, user-defined types have this capability.
In order to do this, we simply use a dot operator to specify a single field within a user-
defined type that we would like to return. For instance, to retrieve only the school_name
field from alice 's education field, we can perform the following query:
SELECT "username", "education"."school_name"
FROM "users"
WHERE "username" = 'alice';
Now, the school name is presented as its own column in the results:
Note
Note that, internally, a user-defined type is stored as a single, indivisible entity; in order to
return a partial value for a user-defined type, Cassandra must, under the hood, deserialize
the entire value and then extract the field we requested. The advantage here is merely that
of avoiding the network bandwidth of transferring extraneous fields within the user-defined
type.
Search WWH ::




Custom Search