Thanks for investigating. Is it something that is fixable on NewRelic's end? Or would Web2py need to change how it submits the query?
>From my brief research, it does seem like psycopg expects queries to be parameterized (ie, using string substitution). However my query works fine when not wrapped by New Relic.