Search code examples
bigtablegoogle-cloud-bigtable

Bigtable - read_rows and start_key


Is there a way to write the start_key for Bigtable? I was not able to find a clear documentation on what the syntax is for start_key.

Suppose I have a row key of {domain}_{timestamp} of user activity.

To filter the query to a specific domain I could use a filter (slower), or a start_key (faster).

I have been writing my start_key string as {domain}_, but what if we now have domain, user ID, and timestamp, and now I want to filter by any user but a specific time, can I use something like {domain}_*_{timestamp}?


Solution

  • You have to use a Filter with RegexStringComparator. You can also setStart({domain}_) for better performance. Unfortunately, that's going to pretty much going to do a scan on {domain}_ and filter on the server-side.

    It might be faster to do a search with either a random user id, or if you need all users, to use Table.get(List<Get>) where each Get correspond to individual user.