<div dir="ltr">

<span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Can I remove the "ORDER BY vtiger_crmentity.modifiedtime DESC" clause<span> </span></span><br style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">globally on vtiger 7.1?</span>

<br><div><br></div><div>What other field would you then sort on ?</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 5, 2018 at 6:04 PM Alan Lord <<a href="mailto:alanslists@gmail.com">alanslists@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Development migration vtiger system (5.4.0 - 7.1.0), fast server, SSDs, <br>
loads of RAM.<br>
<br>
Loading lists is really slow on a fairly large database (crmentity ~5.5m <br>
rows).<br>
<br>
For example; loading a page of Accounts uses the following query:<br>
<br>
SELECT vtiger_account.account_no, vtiger_account.accountname, <br>
vtiger_account.website, vtiger_account.phone, <br>
vtiger_crmentity.smownerid, vtiger_account.accountid, <br>
vtiger_crmentity_user_field.starred FROM vtiger_account INNER JOIN <br>
vtiger_crmentity ON vtiger_account.accountid = vtiger_crmentity.crmid <br>
LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = <a href="http://vtiger_users.id" rel="noreferrer" target="_blank">vtiger_users.id</a> <br>
LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid = <br>
vtiger_groups.groupid LEFT JOIN vtiger_crmentity_user_field ON <br>
vtiger_account.accountid = vtiger_crmentity_user_field.recordid AND <br>
vtiger_crmentity_user_field.userid=1 WHERE vtiger_crmentity.deleted=0 <br>
AND vtiger_account.accountid > 0 ORDER BY vtiger_crmentity.modifiedtime <br>
DESC LIMIT 120,21<br>
<br>
This takes between 3 & 5 seconds.<br>
<br>
If I drop the ORDER BY modifiedtime it's fast, ~0.01s<br>
<br>
I tried adding an index on the modifiedtime column but this made no <br>
difference - MySQL still needs to use filesort and a temporary table.<br>
<br>
Then I dropped that index and created one combining crmid and <br>
modifiedtime - not much better either.<br>
<br>
So, two questions:<br>
<br>
1. Any DBAs know how to speed this up (if possible)<br>
2. Can I remove the "ORDER BY vtiger_crmentity.modifiedtime DESC" clause <br>
globally on vtiger 7.1?<br>
<br>
Cheers<br>
<br>
Al<br>
<br>
<br>
_______________________________________________<br>
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a><br>
</blockquote></div>