fs.quota.cache_hits = 0 设置为0的好处
时间: 2024-04-19 19:29:20 浏览: 133
将 `fs.quota.cache_hits` 设置为0会禁用文件系统的缓存命中机制。在某些情况下,禁用缓存可能有一些好处,例如:
1. 数据一致性:禁用缓存可以确保每次读取都是从磁盘中最新的数据,而不是从缓存中读取可能过期的数据。这对于某些需要实时数据的应用程序可能是必要的。
2. 资源管理:禁用缓存可以减少文件系统使用的内存和其他资源,特别是对于具有大量读取操作的场景。这可以提高系统的整体资源利用率。
然而,需要注意的是,禁用缓存可能会导致读取性能下降,因为每次读取都需要从磁盘中读取数据。因此,在使用 `fs.quota.cache_hits = 0` 之前,请确保你了解其可能带来的影响,并在具体场景中进行评估和测试。
相关问题
改为pgsql select c.* from ( select a.* from ( SELECT t.PROJ_ID,t.PROJ_CODE,t.PROJ_NAME,t.CLIENT_CODE,t.CLIENT_NAME,t.SPEC_CODE,t.SPEC_NAME,t.BUS_UNIT_CODE,t.BUS_UNIT,t.PROJ_DEP_CODE,t.PROJ_DEP,t.PROJECT_MANAGER_CODE,t.PROJECT_MANAGER,t.PROJECT_DEP_MANAGER_CODE,t.PROJECT_DEP_MANAGER,t.IS_SUB_PROJ,t.SUB_PROJ_TYPE_CODE,t.SUB_PROJ_TYPE,t.PARENT_CODE,t.PROJ_GROSS,t.CLIENT_AREA_CODE,t.CLIENT_AREA,t.CLIENT_TYPE_FULL_PATH_CODE,t.CLIENT_TYPE_PULL_PATH,t.BUSINESS_TYPE_CODE,t.BUSINESS_TYPE,t.BUSINESS_LEVEL_CODE,t.BUSINESS_LEVEL,t.BUSINESS_AREA_CODE,t.BUSINESS_AREA_NAME,t.IS_CLOSE,t.IS_IN_COO,t.TAX_RATE,t.IS_AUTHORIZED,t.AUTHORIZED_AMOUNT,t.IS_VIRTUAL,t.INCOME_BUDGET,t.EXPENDITURE_BUDGET,t.P_VALUE,t.CREATE_TIME,t.P_BUD_VALUE,t.P1_BUD_VALUE,t.P2_BUD_VALUE,t.ORG_CODE,t.ORG_NAME,t.PROD_RES_TYPE,t.IS_TECH_COO,t.COO_UNIT_RATIO,t.PROJ_ACHIEVEMENTS_BUD,t.REIMBURSEMENT_COST_BUD,t.COO_COST_BUD,t.MATERIAL_COST_BUD,t.PERFORMANCE_PERCENT,t.SCHE_START_TIME,t.SCHE_END_TIME,t.PROJECT_ACCOUNT_CODE,t.CUSTOMER_TYPE_CODE,t.CUSTOMER_TYPE,t.IS_PURE_OUT_PROJ,t.PROJECT_CREATE_TIME,t.IS_RELATE,t.IS_QUOTA,t.MAIN_PROJECT_CODE,t.PROJ_STATUS,t.IS_LARGE_PROJECT,t.MARKET_DIS_COUNT_RATE,t.PROJECT_CAT,t.MGR_PER_FORMANCE_RATIO,t.P1_VALUE,t.S_VALUE,t.COOP_VALUE,t.H_VALUE,t.DEVICE_BUDGET_COST,t.SUR_FEE_DIS_COUNT_RATE,t.DES_FEE_DIS_COUNT_RATE, (select listagg(p.coo_unit_code, ',') within group(order by p.coo_unit_code) from ( select distinct coo_unit_code from t_spdi_proj where is_sub_proj = 'Y' and sub_proj_type_code = 'wbhz' and PROJ_STATUS != 'P_5' AND PROJ_STATUS != 'P_4' and parent_code = t.proj_code )p ) coo_unit_code, (select listagg(to_char(p.coo_unit), ',') within group(order by p.coo_unit) from ( select distinct coo_unit from t_spdi_proj where is_sub_proj = 'Y' and sub_proj_type_code = 'wbhz' and PROJ_STATUS != 'P_5' AND PROJ_STATUS != 'P_4' and parent_code = t.proj_code )p ) coo_unit from T_SPDI_PROJ t where -- and t.PARENT_CODE=#{parentCode:VARCHAR} t.IS_SUB_PROJ='Y' and t.SUB_PROJ_TYPE_CODE='zz' and t.PROJ_STATUS NOT IN ('E','H','W') order by t.proj_id )a )c
这是一条查询语句,使用了子查询和列表聚合函数。目的是查询出T_SPDI_PROJ表中所有符合条件的子项目(IS_SUB_PROJ='Y',SUB_PROJ_TYPE_CODE='zz',PROJ_STATUS不为'E'、'H'、'W')的信息和其所属的COO_UNIT_CODE和COO_UNIT。其中,COO_UNIT_CODE和COO_UNIT来自于另外一个子查询,该子查询筛选出所有符合条件的子项目(IS_SUB_PROJ='Y',SUB_PROJ_TYPE_CODE='wbhz',PROJ_STATUS不为'P_5'、'P_4')的COO_UNIT_CODE和COO_UNIT,并使用LISTAGG函数将它们合并成一个字符串。最终结果按照PROJ_ID排序。
优化这条sql 解决bug select a.*,rownum num from ( SELECT t.PROJ_ID,t.PROJ_CODE,t.PROJ_NAME,t.CLIENT_CODE,t.CLIENT_NAME,t.SPEC_CODE,t.SPEC_NAME,t.BUS_UNIT_CODE,t.BUS_UNIT,t.PROJ_DEP_CODE,t.PROJ_DEP,t.PROJECT_MANAGER_CODE,t.PROJECT_MANAGER,t.PROJECT_DEP_MANAGER_CODE,t.PROJECT_DEP_MANAGER,t.IS_SUB_PROJ,t.SUB_PROJ_TYPE_CODE,t.SUB_PROJ_TYPE,t.PARENT_CODE,t.PROJ_GROSS,t.CLIENT_AREA_CODE,t.CLIENT_AREA,t.CLIENT_TYPE_FULL_PATH_CODE,t.CLIENT_TYPE_PULL_PATH,t.BUSINESS_TYPE_CODE,t.BUSINESS_TYPE,t.BUSINESS_LEVEL_CODE,t.BUSINESS_LEVEL,t.BUSINESS_AREA_CODE,t.BUSINESS_AREA_NAME,t.IS_CLOSE,t.IS_IN_COO,t.TAX_RATE,t.IS_AUTHORIZED,t.AUTHORIZED_AMOUNT,t.IS_VIRTUAL,t.INCOME_BUDGET,t.EXPENDITURE_BUDGET,t.P_VALUE,t.CREATE_TIME,t.P_BUD_VALUE,t.P1_BUD_VALUE,t.P2_BUD_VALUE,t.ORG_CODE,t.ORG_NAME,t.PROD_RES_TYPE,t.IS_TECH_COO,t.COO_UNIT_RATIO,t.PROJ_ACHIEVEMENTS_BUD,t.REIMBURSEMENT_COST_BUD,t.COO_COST_BUD,t.MATERIAL_COST_BUD,t.PERFORMANCE_PERCENT,t.SCHE_START_TIME,t.SCHE_END_TIME,t.PROJECT_ACCOUNT_CODE,t.CUSTOMER_TYPE_CODE,t.CUSTOMER_TYPE,t.IS_PURE_OUT_PROJ,t.PROJECT_CREATE_TIME,t.IS_RELATE,t.IS_QUOTA,t.MAIN_PROJECT_CODE,t.PROJ_STATUS,t.IS_LARGE_PROJECT,t.MARKET_DIS_COUNT_RATE,t.PROJECT_CAT,t.MGR_PER_FORMANCE_RATIO,t.P1_VALUE,t.S_VALUE,t.COOP_VALUE,t.H_VALUE,t.DEVICE_BUDGET_COST,t.SUR_FEE_DIS_COUNT_RATE,t.DES_FEE_DIS_COUNT_RATE, (select listagg(p.coo_unit_code, ',') within group(order by p.coo_unit_code) from ( select distinct coo_unit_code from t_spdi_proj where is_sub_proj = 'Y' and sub_proj_type_code = 'wbhz' and PROJ_STATUS != 'P_5' AND PROJ_STATUS != 'P_4' and parent_code = t.proj_code )p ) coo_unit_code, (select listagg(to_char(p.coo_unit), ',') within group(order by p.coo_unit) from ( select distinct coo_unit from t_spdi_proj where is_sub_proj = 'Y' and sub_proj_type_code = 'wbhz' and PROJ_STATUS != 'P_5' AND PROJ_STATUS != 'P_4' and parent_code = t.proj_code )p ) coo_unit from T_SPDI_PROJ t where t.PROJ_STATUS NOT IN ('E','H','W') order by t.proj_id )a
这条 SQL 可以进行如下优化:
1. 使用 WITH 语句将子查询提取出来,以降低重复代码并提高可读性。
2. 使用 EXISTS 替代 DISTINCT 子查询,以提高查询效率。
3. 使用 JOIN 替代子查询,以提高查询效率。
4. 使用 UNION ALL 替代 LISTAGG 函数,以提高查询效率。
下面是优化后的 SQL:
WITH subquery AS (
SELECT DISTINCT coo_unit_code, coo_unit
FROM t_spdi_proj
WHERE is_sub_proj = 'Y'
AND sub_proj_type_code = 'wbhz'
AND PROJ_STATUS NOT IN ('P_5', 'P_4')
)
SELECT a.*, rownum num,
(SELECT LISTAGG(p.coo_unit_code, ',') WITHIN GROUP (ORDER BY p.coo_unit_code)
FROM subquery p
WHERE p.parent_code = a.proj_code) coo_unit_code,
(SELECT LISTAGG(p.coo_unit, ',') WITHIN GROUP (ORDER BY p.coo_unit)
FROM subquery p
WHERE p.parent_code = a.proj_code) coo_unit
FROM T_SPDI_PROJ a
WHERE a.PROJ_STATUS NOT IN ('E', 'H', 'W')
ORDER BY a.proj_id;
阅读全文