snippetsqlMinor
How to turn off all RAISE NOTICE on production server?
Viewed 0 times
turnallproductionnoticeraisehowserveroff
Problem
I put a lot of RAISE NOTICE in functions for debugging purpose. I think this will affect performance, so they should be removed on production environment. Is there any way to opt-out those logging/assertion functions only under specific conditions?
Solution
You could wrap them in an
I suspect you'll be better off lowering the log level in the
See the expanded form of the
See the documentation for the
Alternately, you can leave your messages at
So long as the notices aren't doing lots of expensive string formatting or being called huge numbers of times I suspect you won't have too much trouble with their performance impact while logging to file/client is suppressed by log levels.
IF clause that tests a custom configuration variable. This will work but it's a bit verbose and each statement in PL/PgSQL has a cost.I suspect you'll be better off lowering the log level in the
RAISE messages so you log on a level like DEBUG that isn't captured by log_min_messages by default. That way you can just turn it on by changing client_min_messages or log_min_messages.See the expanded form of the
RAISE statement, eg:RAISE DEBUG USING MESSAGE = 'TheMessage';See the documentation for the
RAISE statement.Alternately, you can leave your messages at
RAISE NOTICE and increase the log level, but that may hide other information you'll want to see in the logs. Better to log with a lower priority initially.So long as the notices aren't doing lots of expensive string formatting or being called huge numbers of times I suspect you won't have too much trouble with their performance impact while logging to file/client is suppressed by log levels.
Code Snippets
RAISE DEBUG USING MESSAGE = 'TheMessage';Context
StackExchange Database Administrators Q#39457, answer score: 6
Revisions (0)
No revisions yet.