How to retrieve workflow information

I am evaluating the use of Temporal, and from the documentation, I couldn’t find a way to extract large amounts of records filtered by status.
For example, I have 900k workflows with errors in the receive confirmation task and need to extract the workflow IDs for these 900k workflows. I read that the UI has limitations on the number of records. What method can be used to extract this information?

You can use API or CLI to paginate over large list results. I doubt that you need to paginate through all 900k workflows in UI.

You can also consider using an external DB to keep these records. Insert them from the workflow using activities.

I had already thought about an external database.
Thank you for your response.