QLDB - query - Getting all documents which were inserted after some document of given UUID

0

Hi. I try to build simple transaction system with transactionRequest registry. I store all transactionRequests in separate table. Some other module processes this transactions in batch. Batch process registers all id's of transactionRequest that has been processed. In each subsequent runs, I need to query for all new transactionRequests, registered (inserted) after last processed one (I know id of that request). Currently I query ledger for metadata of transactionRequest with given ID and use metadata.txTime timestamp to query all transactionRequests registered after. That's my approach to get all newest documents starting from some timestamp or documentId but, to be honest, I don't like it. I've red in documentation that it's not good approach to query with *inequality *conditions like: SELECT data.* FROM _ql_committed_transaction_requests WHERE metadata.txTime > 'some_timestamp'

Is there some better solution for that? How can I query for all documents that appeared after some document?

已提问 2 年前776 查看次数
1 回答
1

Yes, queries with with inequality conditions are not recommended because they don't scale well when the amount of data in table grows. There are currently two workarounds to overcome this problem:

  1. Depending on your application architecture, you may consider using Streaming feature of Amazon QLDB to process transactionRegistry records once they created or updated in the table. Steaming sends journal updates to Amazon Kinesis, which can trigger AWS Lambda function to filter out the document and call API of another component or just store it somewhere else for further processing.
  2. Instead of an id, you may capture the timestamp of the last processed transactionRequest record. Then the batch process can trigger Export Journal feature to export Amazon QLDB journal to Amazon S3 starting from that timestamp and then process exported files.
AWS
已回答 2 年前
  • Thank you. Do you have any information if such features will be added in future (near future)?

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则