簡體   English   中英

DynamoDB中時序數據如何設計主鍵?

[英]How do I design a primary key for time-series data in DynamoDB?

我有一個由 8 個實體類型組成的數據 model,我需要圍繞一些訪問模式設計一個 DynamoDB NoSQL model。 訪問模式不是特定於實體的,因此我正在翻譯它們,但大多數訪問模式都依賴於按日期范圍獲取項目。 從之前的相關問題來看,人們通常認為通過 itemID(分區鍵)和日期范圍(排序鍵)獲取項目是常態,但就我而言,我需要通過日期范圍獲取所有實體。

這意味着分區鍵是實體類型,排序鍵是日期范圍。 我對這個說法是否正確?

鑒於數據量很大 (>100GB),我不確定這是否屬實。

更新:訪問模式列表和數據示例

到目前為止的訪問模式如下所示:

Get all transactions during a given date range
Get all transactions during a given date range for a given locationId
Get all transactions during a given date range for a given departmentId
Get all transactions during a given date range for a given categoryId
Get all transactions during a given date range for a given productId
Get all transactions during a given date range for a given transactionItemId
Get all transactions during a given date range for a given supplierId
Get all product on transactions during a given date range

一個交易實體具有以下屬性(我只包含了一個片段,但總共有 52 個屬性):

identifier  
confirmationNumber **(contains date information)**
priceCurrency   
discount    
discountInvoiced    
price   
shippingAmount  
subtotal    
subtotalInclTax 
.
.
.

我認為 DynamoDB 不會讓您對這個用例感到非常高興,您似乎有一堆不同的過濾器類別,這通常不是 DynamoDB 擅長的。

實現將需要通過全局二級索引進行大量數據復制以及熱分區的麻煩。 一般的方法可能是有一個基表,其中 PK 作為日期,時間戳作為 SK。 然后,您可以根據 locationId、departmentId 和您過濾的其他類別創建全局二級索引。 這將導致數據重復,並且取決於您的過濾器類別熱分區。

我可能會使用一個關系數據庫,該數據庫在過濾字段上有索引,並按事務時間進行分區。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM