sqlwatch icon indicating copy to clipboard operation
sqlwatch copied to clipboard

Table [sqlwatch_logger_index_usage_stats] never gets populated

Open RJAF001 opened this issue 4 years ago • 6 comments

Table [sqlwatch_logger_index_usage_stats] never gets populated.

I am using the latest SQLWATCH version.

RJAF001 avatar Nov 12 '21 15:11 RJAF001

I am facing the same problem with SQLWATCH 4.3 and cannot find a way to fix it. Please help

grischtian avatar Mar 21 '22 10:03 grischtian

Is [dbo].[sqlwatch_meta_index] populated?

marcingminski avatar Mar 21 '22 15:03 marcingminski

Yes, all relevant sqlwatch tables have up-to-date data [dbo].[sqlwatch_meta_index] [dbo].[sqlwatch_meta_database] [dbo].[sqlwatch_meta_table]

grischtian avatar Mar 22 '22 09:03 grischtian

Just looked into this and something is weird.

The procedure creates ##sqlwatch_index_usage_stats_collector_1546356805384099A7534C851E48C6D1 and uses sqlwatch_logger_index_usage_stats to populate it. But when starting fresh, this table is empty. Then to populate sqlwatch_logger_index_usage_stats, if the index_usage_age is not negative, there is a join on that temp table. So if the index_usage_age parameter is not changed to something negative, it won't ever get populated.

I changed "Index Usage Age Hours" to -1 in the config to not go into that part of the procedure and it works.

PierreLetter avatar Aug 24 '22 19:08 PierreLetter

Yeah, I think what’s happening is if this is set to > 0, it tries to figure out what stats to collect but on the very first run, it won’t find anything yet so it will just quit.

line 16 https://github.com/marcingminski/sqlwatch/blob/main/SqlWatch.Monitor/Project.SqlWatch.Database/dbo/Procedures/usp_sqlwatch_logger_index_usage_stats.sql

when I developed this functionality, I must have had data in the table already so “it worked on my PC” :)

marcingminski avatar Aug 24 '22 22:08 marcingminski

Setting the age to -1 makes it work. Also, in the code, you set an offset in minutes, but in the settings you state "hours" and a value of 24. I'd recommend commenting out on your own install this whole section for now for those who don't need it.

PierreLetter avatar Aug 25 '22 07:08 PierreLetter