NoSQL: Getting the latest values from tables DynamoDB/Azure Table Storage

后端 未结 3 1960
忘掉有多难
忘掉有多难 2020-12-08 00:39

I have a little problem that needs some suggestions:

  • Lets say we have a few hundred data tables with a few dozen million rows each.
  • Data tables are ti
相关标签:
3条回答
  • 2020-12-08 01:18

    For folks who found this thread but only care about 1 table:

    You can get the latest item from a table in the UI by clicking on the column to sort by those values.

    0 讨论(0)
  • 2020-12-08 01:30

    I just published an article today with some common "recipes" about DynamoDB. One of them is "Storing article revisions, getting always the latest" I think it might interest you :)

    In a nutshell, you can get the latest item using Query(hash_key=..., ScanIndexForward=True, limit=1)

    But, this assumes you have a range_key_defined.

    With Scan, you have no such parameter as ScanIndexForward=false and anyway, you can not rely on the order as data is spread over partitions and the Scan request is then load balanced.

    To achieve you goal with DynamoDB, you may "split" your timestamp this way:

    1. hash_key: date
    2. range_key: time or full timestamp, as you prefer

    Then, you can use the 'trick' of Query + Limit=1 + ScanIndexForward=false

    0 讨论(0)
  • 2020-12-08 01:35

    In general, you probably just want to reverse the timestamp, so it decreases over time, leaving the newest row on top.

    Here's a blog post of mine outlining how to do this with Windows Azure storage: http://blog.smarx.com/posts/using-numbers-as-keys-in-windows-azure.

    UPDATE

    I use DynamoDB for one project, but in a very simplistic way, so I don't have much experience. That said, http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/QueryAndScan.html suggest to me that you can just specify ScanIndexForward=false and Limit=1 to get the last item.

    0 讨论(0)
提交回复
热议问题