<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>Abysmal performance when computing date_assigned, date_resolved, and date_updated (patch included)</title> 
  <pubDate>Fri, 10 Apr 2026 13:09:16 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/4893</link> 
  <atom:link rel="self" type="application/rss+xml" title="Abysmal performance when computing date_assigned, date_resolved, and date_updated (patch included)" href="https://bugs.horde.org/ticket/4893/rss" /> 
  <description>Abysmal performance when computing date_assigned, date_resolved, and date_updated (patch included)</description> 
 
   
   
  <item> 
   <title>Running MySQL 4.1.20-log, PHP 5.1.4, and Whups 1.0-cvs with </title> 
   <description>Running MySQL 4.1.20-log, PHP 5.1.4, and Whups 1.0-cvs with the following table counts:

whups_tickets: 202

whups_logs: 10809



We noticed that any queries joining against whups_logs to compute date_assigned, date_updated, and date_resolved were incredibly slow (ex: My Tickets and Quick Searches).  Based on the nature of the join (text), and after adding indexes to all tables, and tweaking MySQL as far as possible, we patched Whups 1.0 to store (rather than recompute) the date_assigned, date_updated, and date_resolved fields each time.



SQL and code patches follow below. We hope you find them useful and will integrate them into CVS (because we use this in a production environment, we tend to stay 6 months or so behind releases; so, these patches may not be against the latest whups):



The SQL to alter the schema is:

alter table whups_tickets add column date_updated int;

alter table whups_tickets add column date_assigned int;

alter table whups_tickets add column date_resolved int;



The SQL to back-fill the stored columns with freshly computed values is:

update whups_tickets as T1  set date_updated = (select max(whups_logs.log_timestamp) from whups_logs where whups_logs.ticket_id = T1.ticket_id group by whups_logs.ticket_id);



update whups_tickets as T1 set date_assigned =(select max(log_timestamp) from whups_logs inner join whups_states on whups_logs.log_type=&#039;state&#039; and whups_logs.log_value_num=whups_states.state_id and whups_states.state_category=&#039;assigned&#039; where whups_logs.ticket_id=T1.ticket_id group by whups_logs.ticket_id);



update whups_tickets as T1 set date_resolved =(select max(log_timestamp) from whups_logs inner join whups_states on whups_logs.log_type=&#039;state&#039; and whups_logs.log_value_num=whups_states.state_id and whups_states.state_category=&#039;resolved&#039; where whups_logs.ticket_id=T1.ticket_id group by whups_logs.ticket_id);



The code patches are attached.</description> 
   <pubDate>Mon, 15 Jan 2007 00:13:22 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/4893#t28491</link> 
  </item> 
   
  <item> 
   <title>Sounds good. I&#039;ll look at the code patches and see how off t</title> 
   <description>Sounds good. I&#039;ll look at the code patches and see how off they are; if I can&#039;t get it to apply with some massaging I&#039;ll ask you to take a look at the latest CVS.</description> 
   <pubDate>Mon, 15 Jan 2007 01:35:30 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/4893#t28495</link> 
  </item> 
   
  <item> 
   <title>Done in HEAD with not too many tweaks. Thanks!</title> 
   <description>Done in HEAD with not too many tweaks. Thanks!</description> 
   <pubDate>Thu, 18 Jan 2007 03:22:56 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/4893#t28645</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
