can we query sys_history_line table ?

kapil_shinde
Tera Expert

Hi All,

 

need suggestion on query sys_history_line table, is it a good idea to do so. As the table contains huge number of records, which keeps growing. So if a business requirement needs to query this table, shall we decline the requirement. or can we accept it. What we want to check is if a field was modified in last 5 days.

 

Regards

 

Kapil

4 REPLIES 4

AnveshKumar M
Tera Sage
Tera Sage

Hi @kapil_shinde 

 

If you query for the data in last 4 weeks, it is ok otherwise you should not rely one sys_history_line table. As the data in this table is dependent on sys_history_set table to form the relation, which will be cleaned up every 30 days.

 

From my personal experiences, my recommendation is not to use this table. Instead you can create a metric for the field and query the metric instance to check if the value is changed in last 5 days or what ever.

 

Please mark my answer helpful and accept as solution if it helped you 👍✔️

Thanks,
Anvesh

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

What is your actual use case to query this table?

 

In my opinion: avoid as much as possible! Why? This table is only populated when end-users MANUALY view the history of records. If no one did that, you are quering incorrect data / data which is not present.

 

So avoid this as much as possible. Especially when I read "What we want to check is if a field was modified in last 5 days". Than this is not the table to query!

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

What is a good idea, to maintain this table. For example using Table Cleaners.

This one is also mentioned in one of my blogs:
https://www.servicenow.com/community/now-platform-blog/keeping-your-instance-database-footprint-tidy...

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Tai Vu
Kilo Patron
Kilo Patron

Hi @kapil_shinde 

The table should be used is the Sys Audits [sys_audit].

We should not look for data in the sys_history_line table. Refer to this KB #KB0744473

TaiVu_0-1697614820924.png

 

Let me know if it works for you.

 

Cheers,

Tai Vu