Treating Hibernate statements

Many object-relational mappings (ORM), such as Hibernate, generate insanely long SQL statements. The trouble is this: pg_stat_activity will only store the first 1024 bytes of the query in the system view. The rest is truncated. In the case of a long query generated by an ORM such as Hibernate, the query is cut off before the interesting parts (the FROM clause, among others) actually start.

The solution to this problem is to set a config parameter in the postgresql.conf file:

test=# SHOW track_activity_query_size;
track_activity_query_size
---------------------------
1024
(1 row)

If we increase this parameter to a reasonably high value (maybe 32,768) and restart PostgreSQL, we will then be able to see much longer queries, and be able to detect issues more easily.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset