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?

asked 2 years ago765 views
1 Answer
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
answered 2 years ago
  • Thank you. Do you have any information if such features will be added in future (near future)?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions