by eggsurplus

Control what your users can access and save time, money, and frustrations. Lock down sensitive data in SugarCRM or SuiteCRM to specific groups or teams. Supports unlimited assigned users, unlimited group assignments to records, custom layouts for each group, login/sudo capabilities and much more.

Free Trial

By clicking you consent to share your profile with the developer

#522 - SQL Server 2008 R2 slow query

Closed Bug? created by Stefan 10 years ago
If a user is part of a security group and navigates to the accounts section, the following query essentially never completes: SELECT TOP 21 * FROM ( SELECT accounts.id , accounts.name , accounts.shipping_address_street , accounts.shipping_address_city , accounts.shipping_address_state , accounts.shipping_address_postalcode , accounts.phone_office , LTRIM(RTRIM(ISNULL(jt0.first_name,'')+' '+ISNULL(jt0.last_name,''))) assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, accounts.assigned_user_id , ROW_NUMBER() OVER (ORDER BY accounts.date_entered DESC) AS row_number FROM accounts LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c LEFT JOIN users jt0 ON accounts.assigned_user_id=jt0.id AND jt0.deleted=0 AND jt0.deleted=0 where ( ( accounts.assigned_user_id ='xxxxxx' or EXISTS (SELECT 1 FROM securitygroups secg INNER JOIN securitygroups_users secu ON secg.id = secu.securitygroup_id AND secu.deleted = 0 AND secu.user_id = 'xxxxx' INNER JOIN securitygroups_records secr ON secg.id = secr.securitygroup_id AND secr.deleted = 0 AND secr.module = 'Accounts' WHERE secr.record_id = accounts.id AND secg.deleted = 0) ) ) AND accounts.deleted=0 ) AS a WHERE row_number > 0 If a user is not part of a security group, then it completes (sometimes it's still logged as a slow query in sugarcrm.log but performance is acceptable): SELECT TOP 21 * FROM ( SELECT accounts.id , accounts.name , accounts.shipping_address_street , accounts.shipping_address_city , accounts.shipping_address_state , accounts.shipping_address_postalcode , accounts.phone_office , LTRIM(RTRIM(ISNULL(jt0.first_name,'')+' '+ISNULL(jt0.last_name,''))) assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, accounts.assigned_user_id , ROW_NUMBER() OVER (ORDER BY accounts.name ASC) AS row_number FROM accounts LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c LEFT JOIN users jt0 ON accounts.assigned_user_id=jt0.id AND jt0.deleted=0 AND jt0.deleted=0 where ( ( accounts.assigned_user_id ='xxxxxxxxxxxxxxxxx' or EXISTS (SELECT 1 FROM securitygroups secg INNER JOIN securitygroups_users secu ON secg.id = secu.securitygroup_id AND secu.deleted = 0 AND secu.user_id = 'xxxxxxxxxxxxxxx' INNER JOIN securitygroups_records secr ON secg.id = secr.securitygroup_id AND secr.deleted = 0 AND secr.module = 'Accounts' WHERE secr.record_id = accounts.id AND secg.deleted = 0) ) ) AND accounts.deleted=0 ) AS a WHERE row_number > 0 Any help you can give me would be great because the system is essentially useless at this time.
  1. eggsurplus member avatar

    eggsurplus Provider Affiliate

    10 years ago

  2. staganyi member avatar

    Stefan

    10 years ago

  3. staganyi member avatar

    Stefan

    10 years ago

  4. staganyi member avatar

    Stefan

    10 years ago

  5. staganyi member avatar

    Stefan

    10 years ago

  6. staganyi member avatar

    Stefan

    10 years ago

  7. staganyi member avatar

    Stefan

    10 years ago

  8. staganyi member avatar

    Stefan

    10 years ago

  9. staganyi member avatar

    Stefan

    10 years ago

  10. staganyi member avatar

    Stefan

    10 years ago

This case is public. Please leave out any sensitive information such as URLs, passwords, etc.
Saving Comment Saving Comment...
Rating
Rating
  • "No brainer. I have purchased it for two production installations and not regretted it."

    Read More Reviews