How to efficiently get paged query results for a date range

Joe

Just starting out with NoSql in general and DynamodB in particular, and I've been asked the following question:

There is an existing table with a large number of rows with fields something like:

RecordId (Guid = partition key)
RecordType (Guid = sort key)
UserId (Guid)
CreationDateTime
... and some other attributes ...

There is also a GSI (say GSI1) with:

UserId = partition key
RecordType = sort key

Some users generate a large number of rows with the same RecordType (maybe hundreds or thousands per day), so this index typically has a large number of rows with the same UserId+RecordType.

I want to be able to efficiently execute a paged query for results that match a specific UserId+RecordType, and have a CreationDateTime within a range of dates.

What's the best way to achieve this?

It's been suggested to me that I can create a second GSI (say GSI2) with partitionKey = Userid and Sort key = CreationDateTime. The idea being that this would be an efficient way to find the first row for UserId+RecordType that is in the required date range, and that then this would be used as a starting point (PaginationToken) for searching in GSI1. Which would only work if the rows in GSI1 with a duplicate key are stored in order of creation.

Does this make sense? And if not, what would be a better approach?

Eyal Ch

if your query is: "specific UserId+RecordType, and CreationDateTime range" so you answered to yourself:

create GSI:

hash = UserId_RecordType (1234_type1)

range = CreationDateTime

in this way you can get all docs for user with RecordType, sorted by CreationDateTime

be careful with hot keys.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to categories results of a query based on date range

From Dev

How to query rows between specific date range in MySQL efficiently?

From Dev

How to efficiently query for a network (range)?

From Dev

How to get query results only with the latest date?

From Dev

How to efficiently unfold a date range span in Pandas?

From Dev

MySQL query to group results by date range?

From Dev

How to get results from the query if the selected date is between two dates?

From Dev

Get deducted results over date range

From Dev

Get deducted results over date range

From Dev

Efficiently page query results

From Dev

How to get total count of paged data using query.v1

From Dev

MySQL: How do I efficiently reuse the results of a query in other queries?

From Dev

Lucene 4.10.3 numeric date range query does not return expected results

From Dev

How to query documents by date outside of range?

From Dev

How to query documents by date outside of range?

From Dev

Using two date comparisons instead of date range query gives different results in MongoDB

From Dev

java script how to get a date range in days

From Dev

How to get date range for current week?

From Dev

How do I return results of a date range of >=2 days?

From Dev

SQL - Select Data Based on Date Range Efficiently

From Dev

SQL - Select Data Based on Date Range Efficiently

From Dev

Django Date Range Query

From Dev

Date Range Query Elasticsearch

From Dev

Android SQLLITE query to get Date Values within a Particular range

From Dev

Quickest way to get first and last item in ActiveRecord date range query?

From Dev

How does Dynamodb Sort the query results when there is no range key avaialble?

From Dev

How to delete Azure table entities based on range query results

From Dev

Query with date results Formatted

From Dev

SPARQL query to get only results with the most recent date

Related Related

  1. 1

    How to categories results of a query based on date range

  2. 2

    How to query rows between specific date range in MySQL efficiently?

  3. 3

    How to efficiently query for a network (range)?

  4. 4

    How to get query results only with the latest date?

  5. 5

    How to efficiently unfold a date range span in Pandas?

  6. 6

    MySQL query to group results by date range?

  7. 7

    How to get results from the query if the selected date is between two dates?

  8. 8

    Get deducted results over date range

  9. 9

    Get deducted results over date range

  10. 10

    Efficiently page query results

  11. 11

    How to get total count of paged data using query.v1

  12. 12

    MySQL: How do I efficiently reuse the results of a query in other queries?

  13. 13

    Lucene 4.10.3 numeric date range query does not return expected results

  14. 14

    How to query documents by date outside of range?

  15. 15

    How to query documents by date outside of range?

  16. 16

    Using two date comparisons instead of date range query gives different results in MongoDB

  17. 17

    java script how to get a date range in days

  18. 18

    How to get date range for current week?

  19. 19

    How do I return results of a date range of >=2 days?

  20. 20

    SQL - Select Data Based on Date Range Efficiently

  21. 21

    SQL - Select Data Based on Date Range Efficiently

  22. 22

    Django Date Range Query

  23. 23

    Date Range Query Elasticsearch

  24. 24

    Android SQLLITE query to get Date Values within a Particular range

  25. 25

    Quickest way to get first and last item in ActiveRecord date range query?

  26. 26

    How does Dynamodb Sort the query results when there is no range key avaialble?

  27. 27

    How to delete Azure table entities based on range query results

  28. 28

    Query with date results Formatted

  29. 29

    SPARQL query to get only results with the most recent date

HotTag

Archive