I would like to analyze table usage on Verica to check the following
- the tables that are hit most be queries
- tables that are getting more write queries
- tables that are getting more read queries.
So I am asking for help for SQL query or if anyone has any documents please point me in right direction. Thank you.
Here, I create a function
QTYPE()that assigns a request of type 'QUERY' to either a SELECT, an INSERT, or a MODIFY (meaning DELETE,UPDATE,MERGE). The differentiation comes from the fact that, in Vertica, UPDATE/MERGE are actually DELETEs, then INSERTs.I use two regular expressions of a certain complexity: first, finding
[schema.]tablenameafter a JOIN or FROM keyword, then finding[schema.]tablenameafter either the UPDATE, the INSERT INTO, the MERGE INTO and the DELETE FROM keywords. Then, I join back to thetablessystem table to a) only select the tables really existing and b) add the schema name if it is missing.The final report would be:
Here's the function definition, and the CREATE TABLE statement to collect the statistics of what you're looking for, and finally the query getting the 'hit parade' of the most touched tables ...
Mind you, it might become a long runner with a lot of history in your
query_requeststable ...