1.mybatis-plus自定义处理类型无效
场景:自定义与jdbc的数据类型映射,无效。代码如下:
@MappedTypes(JSONArray.class)
@MappedJdbcTypes(JdbcType.VARCHAR)
public class JSONArrayHandler extends BaseTypeHandler<JSONArray> {
@Override
public void setNonNullParameter(PreparedStatement ps, int i, JSONArray parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, String.valueOf(parameter.toJSONString()));
}
@Override
public JSONArray getNullableResult(ResultSet rs, String columnName) throws SQLException {
String sqlJson = rs.getString(columnName);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
@Override
public JSONArray getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String sqlJson = rs.getString(columnIndex);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
@Override
public JSONArray getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String sqlJson = cs.getString(columnIndex);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
}
@Data
@Accessors(chain = true)
@TableName(value = "t_third_product", autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
public class TThirdProduct extends BaseTaskEntity {
/**
* 第三方商品id
*/
private String thirdProductId;
/**
* 规格
*/
@TableField(typeHandler = JSONArrayHandler.class)
private JSONArray specifications;
@TableField(typeHandler = JSONArrayHandler.class)
private JSONArray dimensions;
@TableField(typeHandler = JSONArrayHandler.class)
private JSONArray imagesCopyright;
}
异常:
解决方法:
https://www.jb51.net/article/204841.htm
2.查看慢sql
select * from pg_stat_activity where state<>'idle' and now()-query_start > interval '1 s' order by query_start;
3.查看占用连接数
select count( * ) from pg_stat_activity where state not like '%idle';
4.查看最耗时的sql
select * from pg_stat_statements order by total_time desc limit 5;
5.全表扫描频次最高的sql
select * from pg_stat_user_tables where n_live_tup > 100000 and seq_scan > 0 order by seq_tup_read desc limit 10;