New line characters removed from request column in v_monitor.query_requests
It appears new line characters are converted to space characters in the request column of v_monitor.query_requests. This is a problem because one can no longer determine where comments end. For example:
Original Query:
SELECT 1 -- revenue
FROM transactions;
Logged Query:
SELECT 1 -- revenue FROM transactions;
Original Query:
SELECT 1 -- revenue
FROM transactions;
Logged Query:
SELECT 1 -- revenue FROM transactions;
0
Comments
What Vertica version? Agree with you its not good, but I can't reproduce it, all comments are truncated: Lets try with label: Now extract from QUERY_REQUESTS table: Comments are truncated.
I'm using v7.0.2-1. I also tried from the vsql shell and get the same result as you. We noticed the problem on queries sent through other clients. I'm guessing that the vsql shell strips comments before sending them and some clients do not. I can reproduce the issue when queries are sent from JDBC.
Thanks for your help!
Indeed, odbc: And so we found a workaround/solution - you should truncate comments in your app before sending a query to Vertica server.
Why it should be done on client side (truncate comments)?
Although Vertica 7 supports for 32MB for a single value, system tables fields are limited to 64000 bytes. You can confirm it by creating a dummy query with length more than 64000 bytes (create 65KB of comments - take some Shakespeare sonnet and comment it). You will see that field REQUEST in QUERY_REQUESTS table are limited to 64000 bytes.
I will not post a query, but: So you can rely on field REQUEST in any way(think about case when just a query without comment takes more than 64B - problem).
I've discovered that the table v_internal.dc_requests_issued also has a request column which does not suffer from the same issue. I can't find documentation on this table though. Is it ok practice to use it? And if we do use it and want to join to v_monitor.query_requests is the correct join on transaction_id, request_id, and session_id?
Thanks!
I would say yes but on your own risk. As you pointed its undocumented and Vertica can freely to change an API but in this case its belong to Data Collector and DC is documented well enough.
- http://my.vertica.com/docs/7.1.x/HTML/index.htm#Authoring/SQLReferenceManual/Functions/VerticaFuncti...
- http://my.vertica.com/docs/7.1.x/HTML/index.htm#Attic/Troubleshooting/QueryingDataCollectorTables.ht...
- http://my.vertica.com/docs/7.1.x/HTML/index.htm#Attic/Troubleshooting/WorkingWithDataCollectionLogs....
andFYI: v_internal.dc_requests_issued isn't broken, like v_monitor.query_requests.
@jbondurant_gsn, this isn't really broken. It is as intended.
v_monitor.query_requests
is basically a view intov_internal.dc_requests_issued
. If you look at the view definition, it intentionally removes all line breaks. If line breaks are required - then, as you suggested, usedc_requests_issued
that has the raw data.