<div dir="ltr">Hi,<div><br></div><div style>It's not a bug, but missing feature. It's possible to improve using similar improvements to searches by watchers. If you want to help then you can take a look at recent changes in lib/RT/Tickets_SQL.pm.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 4, 2013 at 5:03 PM, Vegard Vesterheim <span dir="ltr"><<a href="mailto:vegard.vesterheim@uninett.no" target="_blank">vegard.vesterheim@uninett.no</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">A RT (TicketSQL) query like this:<br>
<br>
Queue = 'drift' AND ( Status = 'new' or Status = 'open' or Status =<br>
'stalled' ) AND ( CF.{utstyr} = '<a href="http://ufisaweb.uninett.no" target="_blank">ufisaweb.uninett.no</a>' OR CF.{utstyr} =<br>
'<a href="http://dss2.uninett.no" target="_blank">dss2.uninett.no</a>' OR CF.{utstyr} = '<a href="http://myrhauk.uninett.no" target="_blank">myrhauk.uninett.no</a>' OR CF.{utstyr} =<br>
'<a href="http://angel.uninett.no" target="_blank">angel.uninett.no</a>' OR CF.{utstyr} = '<a href="http://jatoba-esxi2.uninett.no" target="_blank">jatoba-esxi2.uninett.no</a>' OR<br>
CF.{utstyr} = '<a href="http://bold.uninett.no" target="_blank">bold.uninett.no</a>' OR CF.{utstyr} = '<a href="http://nidar.uninett.no" target="_blank">nidar.uninett.no</a>' OR<br>
CF.{utstyr} = '<a href="http://voll.uninett.no" target="_blank">voll.uninett.no</a>' OR CF.{utstyr} = '<a href="http://brekka.uninett.no" target="_blank">brekka.uninett.no</a>' OR<br>
CF.{utstyr} = '<a href="http://www.stroemme.no" target="_blank">www.stroemme.no</a>' OR CF.{utstyr} = '<a href="http://xen.uninett.no" target="_blank">xen.uninett.no</a>' OR<br>
CF.{utstyr} = '<a href="http://jatoba-kvm4.uninett.no" target="_blank">jatoba-kvm4.uninett.no</a>' OR CF.{utstyr} =<br>
'<a href="http://inventory.uninett.no" target="_blank">inventory.uninett.no</a>' OR CF.{utstyr} = '<a href="http://busy.uninett.no" target="_blank">busy.uninett.no</a>' OR CF.{utstyr}<br>
= '<a href="http://ufisa.uninett.no" target="_blank">ufisa.uninett.no</a>' OR CF.{utstyr} = '<a href="http://wildfire.uninett.no" target="_blank">wildfire.uninett.no</a>' OR<br>
CF.{utstyr} = '<a href="http://newfire.uninett.no" target="_blank">newfire.uninett.no</a>' OR CF.{utstyr} = '<a href="http://fou1.uninett.no" target="_blank">fou1.uninett.no</a>' OR<br>
CF.{utstyr} = '<a href="http://kanari.uninett.no" target="_blank">kanari.uninett.no</a>' OR CF.{utstyr} = '<a href="http://dok.uninett.no" target="_blank">dok.uninett.no</a>' OR<br>
CF.{utstyr} = '<a href="http://ebony-kvm5.uninett.no" target="_blank">ebony-kvm5.uninett.no</a>' OR CF.{utstyr} =<br>
'<a href="http://jatoba-kvm12.uninett.no" target="_blank">jatoba-kvm12.uninett.no</a>' )<br>
<br>
gets translated to the following SQL:<br>
<br>
SELECT COUNT(DISTINCT <a href="http://main.id" target="_blank">main.id</a>) FROM Tickets main LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_5 ON (<br>
ObjectCustomFieldValues_5.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_5.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_5.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues_5.CustomField = '8' ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_3 ON (<br>
ObjectCustomFieldValues_3.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_3.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_3.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_3.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_22 ON (<br>
ObjectCustomFieldValues_22.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_22.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_22.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_22.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_19 ON (<br>
ObjectCustomFieldValues_19.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_19.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_19.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_19.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_10 ON (<br>
ObjectCustomFieldValues_10.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_10.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_10.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_10.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_4 ON (<br>
ObjectCustomFieldValues_4.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_4.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_4.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_4.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_8 ON (<br>
ObjectCustomFieldValues_8.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_8.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_8.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues_8.Disabled = '0' ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_21 ON (<br>
ObjectCustomFieldValues_21.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_21.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_21.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_21.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_12 ON (<br>
ObjectCustomFieldValues_12.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_12.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_12.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_12.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_16 ON (<br>
ObjectCustomFieldValues_16.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_16.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_16.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_16.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_17 ON (<br>
ObjectCustomFieldValues_17.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_17.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_17.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_17.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_20 ON (<br>
ObjectCustomFieldValues_20.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_20.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_20.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_20.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_13 ON (<br>
ObjectCustomFieldValues_13.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_13.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_13.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues_13.CustomField = '8' ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_2 ON (<br>
ObjectCustomFieldValues_2.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_2.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues_2.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_2.CustomField = '8' ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_9 ON (<br>
ObjectCustomFieldValues_9.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_9.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_9.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues_9.Disabled = '0' ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_18 ON (<br>
ObjectCustomFieldValues_18.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_18.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_18.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues_18.CustomField = '8' ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_14 ON (<br>
ObjectCustomFieldValues_14.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_14.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_14.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues_14.Disabled = '0' ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_7 ON (<br>
ObjectCustomFieldValues_7.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_7.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_7.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_7.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_6 ON (<br>
ObjectCustomFieldValues_6.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_6.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_6.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_6.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_1 ON (<br>
ObjectCustomFieldValues_1.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_1.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_1.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_1.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_11 ON (<br>
ObjectCustomFieldValues_11.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_11.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_11.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues_11.CustomField = '8' ) LEFT JOIN<br>
ObjectCustomFieldValues ObjectCustomFieldValues_15 ON (<br>
ObjectCustomFieldValues_15.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues_15.CustomField = '8' ) AND (<br>
ObjectCustomFieldValues_15.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues_15.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) WHERE (main.Status !=<br>
'deleted') AND (main.Queue = '6' AND ( main.Status = 'new' or<br>
main.Status = 'open' or main.Status = 'stalled' ) AND ( ( ( (<br>
LOWER(ObjectCustomFieldValues_1.Content) = '<a href="http://ufisaweb.uninett.no" target="_blank">ufisaweb.uninett.no</a>' ) ) )<br>
OR ( ( ( LOWER(ObjectCustomFieldValues_2.Content) = '<a href="http://dss2.uninett.no" target="_blank">dss2.uninett.no</a>' )<br>
) ) OR ( ( ( LOWER(ObjectCustomFieldValues_3.Content) =<br>
'<a href="http://myrhauk.uninett.no" target="_blank">myrhauk.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues_4.Content) = '<a href="http://angel.uninett.no" target="_blank">angel.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues_5.Content) = '<a href="http://jatoba-esxi2.uninett.no" target="_blank">jatoba-esxi2.uninett.no</a>'<br>
) ) ) OR ( ( ( LOWER(ObjectCustomFieldValues_6.Content) =<br>
'<a href="http://bold.uninett.no" target="_blank">bold.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues_7.Content) = '<a href="http://nidar.uninett.no" target="_blank">nidar.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues_8.Content) = '<a href="http://voll.uninett.no" target="_blank">voll.uninett.no</a>' ) ) )<br>
OR ( ( ( LOWER(ObjectCustomFieldValues_9.Content) = '<a href="http://brekka.uninett.no" target="_blank">brekka.uninett.no</a>'<br>
) ) ) OR ( ( ( LOWER(ObjectCustomFieldValues_10.Content) =<br>
'<a href="http://www.stroemme.no" target="_blank">www.stroemme.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues_11.Content) = '<a href="http://xen.uninett.no" target="_blank">xen.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues_12.Content) = '<a href="http://jatoba-kvm4.uninett.no" target="_blank">jatoba-kvm4.uninett.no</a>'<br>
) ) ) OR ( ( ( LOWER(ObjectCustomFieldValues_13.Content) =<br>
'<a href="http://inventory.uninett.no" target="_blank">inventory.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues_14.Content) = '<a href="http://busy.uninett.no" target="_blank">busy.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues_15.Content) = '<a href="http://ufisa.uninett.no" target="_blank">ufisa.uninett.no</a>' ) ) )<br>
OR ( ( ( LOWER(ObjectCustomFieldValues_16.Content) =<br>
'<a href="http://wildfire.uninett.no" target="_blank">wildfire.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues_17.Content) = '<a href="http://newfire.uninett.no" target="_blank">newfire.uninett.no</a>' ) ) )<br>
OR ( ( ( LOWER(ObjectCustomFieldValues_18.Content) = '<a href="http://fou1.uninett.no" target="_blank">fou1.uninett.no</a>' )<br>
) ) OR ( ( ( LOWER(ObjectCustomFieldValues_19.Content) =<br>
'<a href="http://kanari.uninett.no" target="_blank">kanari.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues_20.Content) = '<a href="http://dok.uninett.no" target="_blank">dok.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues_21.Content) = '<a href="http://ebony-kvm5.uninett.no" target="_blank">ebony-kvm5.uninett.no</a>'<br>
) ) ) OR ( ( ( LOWER(ObjectCustomFieldValues_22.Content) =<br>
'<a href="http://jatoba-kvm12.uninett.no" target="_blank">jatoba-kvm12.uninett.no</a>' ) ) ) ) ) AND (main.Type = 'ticket') AND<br>
(main.EffectiveId = <a href="http://main.id" target="_blank">main.id</a>)<br>
<br>
This query takes a very long time to finish.<br>
<br>
A more sensible SQL query would be something like:<br>
<br>
SELECT COUNT(DISTINCT <a href="http://main.id" target="_blank">main.id</a>) FROM Tickets main LEFT JOIN<br>
ObjectCustomFieldValues ON (<br>
ObjectCustomFieldValues.ObjectType = 'RT::Ticket' ) AND (<br>
ObjectCustomFieldValues.Disabled = '0' ) AND (<br>
ObjectCustomFieldValues.ObjectId = <a href="http://main.id" target="_blank">main.id</a> ) AND (<br>
ObjectCustomFieldValues.CustomField = '8' ) WHERE (main.Status !=<br>
'deleted') AND (main.Queue = '6' AND ( main.Status = 'new' or<br>
main.Status = 'open' or main.Status = 'stalled' ) AND ( ( ( (<br>
LOWER(ObjectCustomFieldValues.Content) = '<a href="http://ufisaweb.uninett.no" target="_blank">ufisaweb.uninett.no</a>' ) ) )<br>
OR ( ( ( LOWER(ObjectCustomFieldValues.Content) = '<a href="http://dss2.uninett.no" target="_blank">dss2.uninett.no</a>' )<br>
) ) OR ( ( ( LOWER(ObjectCustomFieldValues.Content) =<br>
'<a href="http://myrhauk.uninett.no" target="_blank">myrhauk.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues.Content) = '<a href="http://angel.uninett.no" target="_blank">angel.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues.Content) = '<a href="http://jatoba-esxi2.uninett.no" target="_blank">jatoba-esxi2.uninett.no</a>'<br>
) ) ) OR ( ( ( LOWER(ObjectCustomFieldValues.Content) =<br>
'<a href="http://bold.uninett.no" target="_blank">bold.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues.Content) = '<a href="http://nidar.uninett.no" target="_blank">nidar.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues.Content) = '<a href="http://voll.uninett.no" target="_blank">voll.uninett.no</a>' ) ) )<br>
OR ( ( ( LOWER(ObjectCustomFieldValues.Content) = '<a href="http://brekka.uninett.no" target="_blank">brekka.uninett.no</a>'<br>
) ) ) OR ( ( ( LOWER(ObjectCustomFieldValues.Content) =<br>
'<a href="http://www.stroemme.no" target="_blank">www.stroemme.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues.Content) = '<a href="http://xen.uninett.no" target="_blank">xen.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues.Content) = '<a href="http://jatoba-kvm4.uninett.no" target="_blank">jatoba-kvm4.uninett.no</a>'<br>
) ) ) OR ( ( ( LOWER(ObjectCustomFieldValues.Content) =<br>
'<a href="http://inventory.uninett.no" target="_blank">inventory.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues.Content) = '<a href="http://busy.uninett.no" target="_blank">busy.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues.Content) = '<a href="http://ufisa.uninett.no" target="_blank">ufisa.uninett.no</a>' ) ) )<br>
OR ( ( ( LOWER(ObjectCustomFieldValues.Content) =<br>
'<a href="http://wildfire.uninett.no" target="_blank">wildfire.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues.Content) = '<a href="http://newfire.uninett.no" target="_blank">newfire.uninett.no</a>' ) ) )<br>
OR ( ( ( LOWER(ObjectCustomFieldValues.Content) = '<a href="http://fou1.uninett.no" target="_blank">fou1.uninett.no</a>' )<br>
) ) OR ( ( ( LOWER(ObjectCustomFieldValues.Content) =<br>
'<a href="http://kanari.uninett.no" target="_blank">kanari.uninett.no</a>' ) ) ) OR ( ( (<br>
LOWER(ObjectCustomFieldValues.Content) = '<a href="http://www3.uninett.no" target="_blank">www3.uninett.no</a>' ) ) ) OR (<br>
( ( LOWER(ObjectCustomFieldValues.Content) = '<a href="http://ebony-kvm5.uninett.no" target="_blank">ebony-kvm5.uninett.no</a>'<br>
) ) ) OR ( ( ( LOWER(ObjectCustomFieldValues.Content) =<br>
'<a href="http://jatoba-kvm12.uninett.no" target="_blank">jatoba-kvm12.uninett.no</a>' ) ) ) ) ) AND (main.Type = 'ticket') AND<br>
(main.EffectiveId = <a href="http://main.id" target="_blank">main.id</a>);<br>
<br>
This query is much more effective. Is this a bug?<br>
<br>
- Vegard V -<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
RT Training in Seattle, June 19-20: <a href="http://bestpractical.com/training" target="_blank">http://bestpractical.com/training</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Best regards, Ruslan.
</div>