# Temporal Querying Problem

**URL:** <https://community.temporal.io/t/temporal-querying-problem/19508>\
**Category:** Community Support\
**Tags:** query\
**Created:** [April 27, 2026, 5:05am UTC](https://community.temporal.io/t/temporal-querying-problem/19508 "2026-04-27T05:05:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubhanshu\_Sharma](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/shubhanshu_sharma/32/7134_2.png) [@Shubhanshu\_Sharma](https://community.temporal.io/u/Shubhanshu_Sharma)\
**Post date:** [April 27, 2026, 5:05am UTC](https://community.temporal.io/t/temporal-querying-problem/19508/1 "2026-04-27T05:05:46Z")

</div>

In Temporal, for a single workflow ID, there can be **multiple executions over time**.

Right now, when we query workflows, we get **all executions** for each workflow ID.

However, the requirement is to get **only the latest execution** for each workflow ID (based on the most recent start time), whether it is running or completed.

The issue is that Temporal does not provide a direct way to filter and return only the latest execution per workflow ID.

| Workflow ID | Run ID | Start Time | Status |
| --- | --- | --- | --- |
| A | r1 | 10:00 AM | Completed |
| A | r2 | 10:05 AM | Failed |
| A | r3 | 10:10 AM | Running |
| B | r4 | 10:02 AM | Completed |
| B | r5 | 10:08 AM | Running |

### 👉 Current Output (what we get)

All executions:

- A → r1, r2, r3

- B → r4, r5

### 👉 Expected Output (what we want)

Only latest per workflow:

- A → r3 (latest)

- B → r5 (latest)

## Why this is a problem

- Since each workflow ID can have **multiple executions** , the total number of records becomes very large.

- When we query this data, it **takes more time** because we are fetching unnecessary older executions as well.

- After fetching, we still need to **manually filter (deduplicate)** the data on the client side to keep only the latest execution per workflow ID.

- This makes the whole process:

---

<div class="post-metadata">

**Author:** ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)\
**Post date:** [April 27, 2026, 2:44pm UTC](https://community.temporal.io/t/temporal-querying-problem/19508/2 "2026-04-27T14:44:52Z")

</div>

Hi,

> The issue is that Temporal does not provide a direct way to filter and return only the latest execution per workflow ID.  
> This is a known limitation, ref [List Workflow Executions ignoring previous runs · Issue #351 · temporalio/temporal · GitHub](https://github.com/temporalio/temporal/issues/351)

For complex queries, the recommendation is to push the data to an external database. There are several strategies, it depends on your requirements

- query periodically (listWorkflowExecutions) and update the external source
- Add an activity at the end of your workflow execution to push the data
- observe the internal workflow state and run an activity if it changes

Also note that the visibility API (ListWorkflowExecution) is eventually consistent

Antonio

---

<div class="post-metadata">

**Author:** ![matthew-percy\_cba](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@matthew-percy\_cba](https://community.temporal.io/u/matthew-percy_cba)\
**Post date:** [May 8, 2026, 12:21am UTC](https://community.temporal.io/t/temporal-querying-problem/19508/3 "2026-05-08T00:21:16Z")

</div>

Have you looked at the DescribeWorkflowExecution call (temporal workflow describe)? It only requires workflow ID, and will give you back the latest run ID for that workflow ID.
