Limiting Query Responses

How can I limit the length of my response? For example, when I’m querying workflows, how can I limit the response to the 10 most recent workflows? Or offset by 20 (exclude the most recent 20)?

Can you give more info please? Are you querying via tctl or api (ListWorkflowExecutions and then query each from result) maybe?

I am querying via api. Here’s where I am sending my query:

  private static ListWorkflowExecutionsResponse getExecutionsResponse(String query) {
    ListWorkflowExecutionsRequest listWorkflowExecutionRequest =
        ListWorkflowExecutionsRequest.newBuilder()
            .setNamespace(client.getOptions().getNamespace())
            .setQuery(query)
            .build();
    ListWorkflowExecutionsResponse listWorkflowExecutionsResponse =
        service.blockingStub().listWorkflowExecutions(listWorkflowExecutionRequest);
    return listWorkflowExecutionsResponse;

where a query can look something like: “ExecutionStatus=2 or ExecutionStatus=3”. Is there a way to alter my query to only return last certain # or offset? Is there some other function? Or do I have to filter that manually?

With the paginated list apis like ListWorkflowExecutions you can set a page size, each page size default is 1000 results. Seems you are looking for more fine-grained filtering on that level.

One thing you can do is use the workflow execution WorkflowType, StartTime and CloseTime (as well as other search attributes), for example:

WorkflowType="MyWorkflowType" AND ExecutionStatus="Completed" and StartTime BETWEEN 1657645620000000000 AND 1657646100000000000

Note that both times are epoch time in nanos. This would allow you to do more fine-grained filtering. Hope this helps.

You can also do something like:

WorkflowType="MyWorkflowType" AND ExecutionStatus="Running" and StartTime >  1657645620000000000

etc.

You can see all search attributes via tctl:

tctl cl gsa