Reputation: 609
I have been using SAP HANA db instance, and have been running several queries on this. I need to extract the query-history, preferably from a system-table or elsewhere. Please let me know if this is possible and any pointers to achieve it, if possible.
Upvotes: 4
Views: 17689
Reputation: 367
handy grep commands forc finding trace files:
# find / -name *.trc # finding trace files
$ grep -n -B 5 -A 1 '^.*select.*$' flatfile # displays matches in a flatfile with context and line numbers ( surrounding five lines above and 1 line below )
$ grep -n -B 5 -A 1 '^.*select\|84443781510009.*$' flatfile # <- or statement for keywords with \| characters
hana studio allows you to apply configuration to tracing behavior (tracing only for a given user, object etc) it is best to change this behavior from hana studio / hdbsql level
As mentioned earlier M_SQL_PLAN_CACHE and M_SQL_PLAN_CACHE_RESET system views allow for handy querying and retrieving executed sql statements as well as their statistics.
Upvotes: 0
Reputation: 1803
If you want a detailed history of executed queries, you need to activate the HANA SQL trace. You can find more information in the HANA documentation. Of course, this will not work retrospectively. So you will have to activate the trace first and then run the queries that you want to look at.
Additionally, the SQL Plan Cache provides aggregated information about past queries. It is aggregated by the prepared statements and provides runtime information like average execution time and result size. The monitoring view for this is SYS.M_SQL_PLAN_CACHE
.
Upvotes: 7