SET extra_float_digits = 3 in postgresql

Whenever I run the Postgresql DB mechanism, I have almost 7-8 queries running in the background SET extra_float_digits = 3

I'm not sure why they work all the time. I know that the extra_float_digits variable adjusts the number of digits displayed for floating point values ​​in Postgresql, however I'm not sure why these queries are executed in the background when the database engine starts.

I already have extra_float_digits = 3 in the configuration file. Even if I comment on this, these requests are still running in the background.

need help .. thanks

+7
sql database postgresql
source share
4 answers

Requests do not work. As Nick says in the comments, the connections will be in standby mode. pg_stat_activity shows the last statement that completed execution when the request is inactive.

As for the other part: I would say that you are using PgJDBC. SET extra_float_digits ensures that PgJDBC does not lose precision when receiving floating point values ​​from the database. This is part of the initial communication session. This is normal and you can ignore it. If you are in recent PgJDBC, send the optional connection parameter assumeMinServerVersion=9.0 and it will disappear .

So, you have a bunch of new, broken connections.

View the configuration of your application / application server. Your connection pool may not have reasonable limits.

+8
source share

I had this problem with Java and Postgresql. I resolved this issue using the connection PGPoolingDataSource and Close.

This is how I built my classes:

// Factory Class Connection:

 public class FacConn { public static PGPoolingDataSource getConnection2() { PGPoolingDataSource source = new PGPoolingDataSource(); source.setServerName("local"); source.setPortNumber(5432); source.setDatabaseName("mydbname"); source.setUser("LoginUser"); source.setPassword("password"); source.setAssumeMinServerVersion("9.0"); source.setConnectTimeout(50000); return source; } } 

// class userDAO - a class for interacting with the database

 public class UsuarioDAO { private PGPoolingDataSource poolDS = FabConexao.getConnection2(); private Connection con = null; public User searchById(Integer id){ try{con = poolDS.getConnection();} catch (SQLException e){throw new RuntimeException(e);} String sql = "Select * from people where id_people=?"; ResultSet rs = null; try (PreparedStatement smtm = con.prepareStatement(sql)){ smtm.setInt(1, id); rs = smtm.executeQuery(); People people = new People(); if(rs.next()){ people.setId_People(rs.getInt("id_people")); people.setFirtname(rs.getString("firstname")); people.setLastname(rs.getString("lastname")); people.setAge(rs.getInt("age")); people.setActiv(rs.getBoolean("activ")); } smtm.close(); return people; } catch (SQLException e){ e.printStackTrace(); System.err.println( e.getClass().getName()+": "+ e.getMessage() ); } finally { if (rs != null) { try {rs.close();} catch (SQLException e) { /* ignored */} } poolDS.close(); } return null; } 
+1
source share

When a new connection is established, postgres runs this extra_float_digits parameter. The problem was related to my database health check module.

0
source share

in my option, you can terminate this connection using the pg command. For example:

SELECT pg_terminate_backend (t.pid) FROM (SELECT pid FROM pg_stat_activity WHERE state = 'idle' AND query like '% float%' AND state_change <(now () - interval '1 hour')) AS t;

0
source share

All Articles