<div dir="ltr">I suppose in this case the problem is that query to identify records to delete takes a long time, but number of actual records to delete is small. In that case it makes sense to prolong the 'garbage collection' period. If the number of records to delete is big, and that causes a long table lock then the situation with bigger timeout may make things even worse.<div><br></div><div>Did you maybe check what indexes are set on this table if any? Depending on the database, creating a different index or changing an index type can make a huge difference.</div><div><br></div><div>Another way to maybe address this would be to only delete small number of records at a time:</div><div><br></div><div>delete from EVENT_ENTITY where EVENT_ID in (select EVENT_ID from EVENT_ENTITY where REALM_ID=:1 and EVENT_TIME<:2 limit 100)</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 30, 2015 at 2:33 PM, Hipfinger Martin (<a href="http://bcc.xn--bb-eka.ticketshop.ma">BCC.ÖBB.TicketShop.MA</a>) <span dir="ltr"><<a href="mailto:Martin.Hipfinger@oebb.at" target="_blank">Martin.Hipfinger@oebb.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="DE-AT" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="EN-GB">we’ve enabled event logging in Realm -> Events -> Config: Save Events ON, Expiration: 365 days<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">KC executes the following statement every 15 minutes:
</span><b><span lang="EN-GB" style="font-family:"Courier New";color:#4444dd">delete</span></b><span><span lang="EN-GB" style="font-family:"Courier New";color:black"> </span></span><b><span lang="EN-GB" style="font-family:"Courier New";color:#4444dd">from</span></b><span><span lang="EN-GB" style="font-family:"Courier New";color:black"> </span></span><span lang="EN-GB" style="font-family:"Courier New";color:black">EVENT_ENTITY<span><span style="font-family:"Courier New""> </span></span></span><b><span lang="EN-GB" style="font-family:"Courier New";color:#4444dd">where</span></b><span><span lang="EN-GB" style="font-family:"Courier New";color:black"> </span></span><span lang="EN-GB" style="font-family:"Courier New";color:black">REALM_ID=:1<span><span style="font-family:"Courier New""> </span></span></span><b><span lang="EN-GB" style="font-family:"Courier New";color:#4444dd">and</span></b><span><span lang="EN-GB" style="font-family:"Courier New";color:black"> </span></span><span lang="EN-GB" style="font-family:"Courier New";color:black">EVENT_TIME<:2<span><span style="font-family:"Courier New""> <u></u><u></u></span></span></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">As the table event_entity is quite big, we’d like to reduce the frequency of deletion – so I’d like to ask if there is any possibility to change the execution schedule of deletion?
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal">Thx & br,<u></u><u></u></p>
<p class="MsoNormal">Martin<u></u><u></u></p>
</div>
</div>
<br>_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br></blockquote></div><br></div>