1.mybatis-plus自定义处理类型无效

场景:自定义与jdbc的数据类型映射,无效。代码如下:

  1. @MappedTypes(JSONArray.class)
  2. @MappedJdbcTypes(JdbcType.VARCHAR)
  3. public class JSONArrayHandler extends BaseTypeHandler<JSONArray> {
  4. @Override
  5. public void setNonNullParameter(PreparedStatement ps, int i, JSONArray parameter, JdbcType jdbcType) throws SQLException {
  6. ps.setString(i, String.valueOf(parameter.toJSONString()));
  7. }
  8. @Override
  9. public JSONArray getNullableResult(ResultSet rs, String columnName) throws SQLException {
  10. String sqlJson = rs.getString(columnName);
  11. if (null != sqlJson){
  12. return JSONArray.parseArray(sqlJson);
  13. }
  14. return null;
  15. }
  16. @Override
  17. public JSONArray getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
  18. String sqlJson = rs.getString(columnIndex);
  19. if (null != sqlJson){
  20. return JSONArray.parseArray(sqlJson);
  21. }
  22. return null;
  23. }
  24. @Override
  25. public JSONArray getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
  26. String sqlJson = cs.getString(columnIndex);
  27. if (null != sqlJson){
  28. return JSONArray.parseArray(sqlJson);
  29. }
  30. return null;
  31. }
  32. }
  1. @Data
  2. @Accessors(chain = true)
  3. @TableName(value = "t_third_product", autoResultMap = true)
  4. @EqualsAndHashCode(callSuper = true)
  5. public class TThirdProduct extends BaseTaskEntity {
  6. /**
  7. * 第三方商品id
  8. */
  9. private String thirdProductId;
  10. /**
  11. * 规格
  12. */
  13. @TableField(typeHandler = JSONArrayHandler.class)
  14. private JSONArray specifications;
  15. @TableField(typeHandler = JSONArrayHandler.class)
  16. private JSONArray dimensions;
  17. @TableField(typeHandler = JSONArrayHandler.class)
  18. private JSONArray imagesCopyright;
  19. }

异常:

postgresql常见问题 - 图1

解决方法:

postgresql常见问题 - 图2

https://www.jb51.net/article/204841.htm

2.查看慢sql

  1. select * from pg_stat_activity where state<>'idle' and now()-query_start > interval '1 s' order by query_start;

3.查看占用连接数

  1. select count( * ) from pg_stat_activity where state not like '%idle';

4.查看最耗时的sql

  1. select * from pg_stat_statements order by total_time desc limit 5;

5.全表扫描频次最高的sql

  1. select * from pg_stat_user_tables where n_live_tup > 100000 and seq_scan > 0 order by seq_tup_read desc limit 10;