Users are always sending their location (long, lat) to Cassandra to store their location into a time series table.
CREATE TABLE locations (
organization_id int,
user_id int,
date text,
unix_time bigint,
lat double,
long double,
PRIMARY KEY ((organization_id, user_id, date), unix_time)
) WITH CLUSTERING ORDER BY (unix_time DESC);
What's the advice when it comes to retrieve the last location of multiple users?
As I will be using LIMIT
as something like that:
SELECT * from myapp.locations WHERE organization_id=1 and user_id in (15,16, 17, 18, 19, 20) and date='2017-2-23' LIMIT 6;
What if last 6 records belongs to the same user? thus, won't get last locations of other users..
Shall create another table that keeps only one location of each user? and keep updating location of each user in it?
What's the advice here?