0
  1. 我的要求是获取多个表数据(超过 200K 行)并转换为 Json 并返回。

  2. 我可以通过两种方式实现上述目标(如果有其他方法请建议我)

    一个。在查询本身中将 DB 数据转换为 Json(array_to_json(array_agg() 或 json_agg())) b. 获取 DB 数据并使用 rowmapper 等转换为 Java 对象列表,然后将 Java 对象列表转换为 json。

  3. 我的观察与这两种方式有关,

    一个。在查询本身中将 DB 数据转换为 Json(array_to_json(array_agg() 或 json_agg()):

    1. array_to_json(array_agg()) is taking long time and which is leading to crash my application
    2. replaced array_to_json(array_agg()) with json_agg() and query execution is taking long time(infact more than array_to_json(array_agg())) here too.
    

    b.获取数据库数据并使用rowmapper等转换为Java对象列表,然后将Java对象列表转换为json:

    1. Application crahsed with outofmemory issue while parsing list of java objects(Count would be more than 200K) to Json
    

数据库:Postgres

询问:

SELECT array_to_json(array_agg(dev_info)) FROM (select * from device_instance_global join device_active_global on device_instance_global.device_id=device_active_global.device_id join dev_management on device_active_global.system_id=dev_management.node_id join device_model on device_active_global.device_code=device_model.device_code and device_instance_global.device_error_class=device_model .device_severity
where dev_management.node_type<>'F' order by device_instance_global.device_raise_time DESC ) dev_info;


从device_instance_global 选择 * dev_management.node_type<>'F' order by device_instance_global.device_raise_time DESC ) dev_info;

请建议我有什么最好的方法来满足我的要求。

4

0 回答 0