JSON_OBJECT(OLD.ID, OLD.BUSINESS_ID, OLD.APPLICATION_DATE , OLD.FINISH_DATE, OLD.LINKMAN_ID, OLD.TOMB_ID, OLD.TOMB_STONE_ID, OLD.ASH_BUSINESS_ID,OLD.REGISTER_USER, OLD.REGISTER_USER_NAME, OLD.REGISTER_DATE, OLD.DEPT_ID, OLD.DEPT_NAME, OLD.`STATUS`, OLD.BOOK_ID, OLD.BUSINESS_VERSION, OLD.IS_CREATEWORK, OLD.IS_SENDCUSTOMER, OLD.SEND_USER, OLD.SEND_DATE, OLD.USER_NAME, OLD.TOMB_DESIGNER, OLD.TOMB_DESIGNER_ID, OLD.DESIGN_START_DATE, OLD.DESIGN_END_DATE, OLD.TOMB_CERTIFICATE_NO, OLD.CONTRACT_NO, OLD.CONTRACT_PRINT_NUM, OLD.CUSTOMER_LOCK, OLD.CUSTOMER_USER, OLD.CUSTOMER_DATE, OLD.PRE_BOOK_ID, OLD.EARNEST_DATE, OLD.PAYOFF_DATE, OLD.INVOICE_DATE, OLD.LINKMAN_NAME, OLD.VALIDATE_DATE, OLD.LAYER_CODE_NEW2, OLD.BURY_DATE_REMARK, OLD.DESIGN_DATE_REMARK, OLD.OLD_TOMB_ID, OLD.CONTRACT_DATE, OLD.LINKMAN_BEFORE_ID, OLD.IF_SAVE, OLD.COLLECT_VERSION)优化一下
时间: 2024-03-28 15:37:07 浏览: 126
我的关于JSON例子
这是一个 SQL 语句,不是 JSON,可以通过以下步骤进行优化:
1. 将 OLD 表示的表名改为实际的表名,这样可以减少解析时间。
2. 将 SELECT 子句中只查询必要的列,避免查询不必要的列,减少 IO 和 CPU 的消耗。
3. 如果可能,可以将一些列合并为一个 JSON 字段,减少查询的列数和数据量。
下面是一个优化后的 SQL 语句示例:
SELECT JSON_OBJECT(
'id', OLD.ID,
'business_id', OLD.BUSINESS_ID,
'application_date', OLD.APPLICATION_DATE,
'finish_date', OLD.FINISH_DATE,
'linkman_id', OLD.LINKMAN_ID,
'tomb_id', OLD.TOMB_ID,
'tomb_stone_id', OLD.TOMB_STONE_ID,
'ash_business_id', OLD.ASH_BUSINESS_ID,
'register_user', OLD.REGISTER_USER,
'register_user_name', OLD.REGISTER_USER_NAME,
'register_date', OLD.REGISTER_DATE,
'dept_id', OLD.DEPT_ID,
'dept_name', OLD.DEPT_NAME,
'status', OLD.`STATUS`,
'book_id', OLD.BOOK_ID,
'business_version', OLD.BUSINESS_VERSION,
'is_creatework', OLD.IS_CREATEWORK,
'is_sendcustomer', OLD.IS_SENDCUSTOMER,
'send_user', OLD.SEND_USER,
'send_date', OLD.SEND_DATE,
'user_name', OLD.USER_NAME,
'tomb_designer', OLD.TOMB_DESIGNER,
'tomb_designer_id', OLD.TOMB_DESIGNER_ID,
'design_start_date', OLD.DESIGN_START_DATE,
'design_end_date', OLD.DESIGN_END_DATE,
'tomb_certificate_no', OLD.TOMB_CERTIFICATE_NO,
'contract_no', OLD.CONTRACT_NO,
'contract_print_num', OLD.CONTRACT_PRINT_NUM,
'customer_lock', OLD.CUSTOMER_LOCK,
'customer_user', OLD.CUSTOMER_USER,
'customer_date', OLD.CUSTOMER_DATE,
'pre_book_id', OLD.PRE_BOOK_ID,
'earnest_date', OLD.EARNEST_DATE,
'payoff_date', OLD.PAYOFF_DATE,
'invoice_date', OLD.INVOICE_DATE,
'linkman_name', OLD.LINKMAN_NAME,
'validate_date', OLD.VALIDATE_DATE,
'layer_code_new2', OLD.LAYER_CODE_NEW2,
'bury_date_remark', OLD.BURY_DATE_REMARK,
'design_date_remark', OLD.DESIGN_DATE_REMARK,
'old_tomb_id', OLD.OLD_TOMB_ID,
'contract_date', OLD.CONTRACT_DATE,
'linkman_before_id', OLD.LINKMAN_BEFORE_ID,
'if_save', OLD.IF_SAVE,
'collect_version', OLD.COLLECT_VERSION
) FROM table_name AS OLD;
阅读全文