This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new 1955c487 [ISSUE #1599] Optimize Tencent countTopics to avoid full 
topic scan (#1600)
1955c487 is described below

commit 1955c48738c21eb5bb1a1fa8e9edcd61e81b05e1
Author: Yu Xinqiang <[email protected]>
AuthorDate: Tue Aug 11 20:28:56 2026 +0800

    [ISSUE #1599] Optimize Tencent countTopics to avoid full topic scan (#1600)
    
    countTopics fetched ALL topics via API just to return .size(), causing
    extreme latency on the instance list page. This fix fetches only 1 item
    to get the total count from the API response, falling back to full scan
    only if the total count field is unavailable.
    
    Fixes #1599
---
 .../studio/provider/tencent/TencentInstanceProvider.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProvider.java
 
b/server/src/main/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProvider.java
index f1d8c6a3..5ab7482d 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProvider.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/provider/tencent/TencentInstanceProvider.java
@@ -80,7 +80,19 @@ public class TencentInstanceProvider implements 
InstanceProvider {
 
     @Override
     public int countTopics(String instanceId) {
-        return listTopics(instanceId, null, null, false).size();
+        Context context = resolve(instanceId);
+        DescribeTopicListRequest request = new DescribeTopicListRequest();
+        request.setInstanceId(context.cloudInstanceId());
+        request.setOffset(0L);
+        request.setLimit(1L);
+        DescribeTopicListResponse response = 
clientFactory.call(context.credentialId(), context.regionId(),
+                client -> client.DescribeTopicList(request));
+        if (response == null || response.getData() == null || 
response.getData().length == 0) {
+            return 0;
+        }
+        // Use the response total count if available; otherwise fall back to 
full scan
+        Long total = response.getTotalCount();
+        return total != null ? Math.toIntExact(total) : listTopics(instanceId, 
null, null, false).size();
     }
 
     @Override

Reply via email to