In postgresql a query in the querylog gets something like this:
2009-02-05 00:12:27 CET LOG: duration: 3781.634 ms execute <unnamed>: SELECT QUERY ....
Is there a possibility to put something more usable into the ‘< unnamed >’ placed like the url the query was requested from?
Are there any other possibilities to track the origin of a query in postgresql using jdbc from java?
Thanks
Short answer is ‘no’
The name can be set when preparing the statement, using the PREPARE command, but that requires rewriting all your SQL. There is no option to simply add a name parameter to your JDBC methods.
The JDBC driver makes use of both named and unnamed prepared statements. It will give them a name when it wishes to reuse them, which it will deem appropriate if the same PreparedStatement object is executed 5 times (though that is configurable through setting the prepareThreshold).
Documentation is here
More info can also be found by searching the PostgreSQL JDBC mailling list