Options

Session Event Table - Delete dormant records

Toddy_BoyToddy_Boy Member Posts: 231
Dear all

We have a growing Session Event table in Nav 2013. I can't see anything obvious or damaging that'll prevent me from deleting these records nightly via SQL or CAL.

Does anyone else maintain this table in any other way?
Life is for enjoying ... if you find yourself frowning you're doing something wrong

Best Answer

Answers

  • Options
    Toddy_BoyToddy_Boy Member Posts: 231
    Great stuff, thanks for that :)
    Life is for enjoying ... if you find yourself frowning you're doing something wrong
  • Options
    RemkoDRemkoD Member Posts: 100
    In NAV 2017 we still have issues with a fast growing Session Event table and instability in the NAV platform related to the Session Event table. Using the Session Event Table Retain Period wasn’t enough for us. We still had too many records in the table causing trouble. I thought I will share our findings and work-around regarding the Session Event table.

    We experience unexpected NAV (background) session crashes caused by a lock on the Session Event table. Also we encountered multiple situations where the Session Event table contains millions and millions of records. These are caused mostly by web service sessions (doesn’t retain a session so each call causes two records) and NAV background sessions (caused by repetitive tasks in the task scheduler).

    Luckily Microsoft has resolved most of our issues in cumulative updates. <3

    NAV 2017 CU12 (Build 18976)
    229689 Add a missing index to the Active Session table.*
    * This fix also includes the removal of explicit locks on the Session Event table. Resolving the session crashes due to a lock.

    NAV 2017 CU11 (build-18609)
    228726 Many records are accumulated in the SESSION EVENT table with Client Type 2 (Web Service).

    NAV 2017 CU8 (build-17501)
    219368 The Session Event table grows too fast.

    In some situations we have not deployed the latest CU yet. Setting the NST Session Event Table Retain Period on 1 month wasn’t enough either. So we use a SQL job by keeping the Session Event table nice and tidy.
    /*
    Delete Session Event records for NAV background sessions and NAV web service sessions (SOAP and OData) older than 7 days from the Session Event table 
    */
    DELETE FROM [dbo].[Session Event] WHERE ([Client Type] = 2 OR [Client Type] = 5) AND DATEDIFF(DD, [Event Datetime], GETDATE()) > 7
    

    Before I create the job I clean up the Session Event table once manually with TRUNCATE because I do not want the millions of rows passing through the SQL transaction log. I have an example here: Pastebin thingy

    I think the amount of records created by background sessions is not yet resolved. So I will stick to the work around until we've found a pretty solution :smile:
Sign In or Register to comment.