Results 1 to 4 of 4

Thread: SQL Query Benchmark needed!

  1. #1
    madmat is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    Germany
    Posts
    164

    Exclamation SQL Query Benchmark needed!

    Hey folks,

    could you do me a favour and run this query:

    Code:
    SELECT  contacts.id,  contacts.first_name, contacts.last_name as name, contacts.salutation  , accounts.name account_name, jtl0.account_id account_id, contacts.phone_work , contacts.assigned_user_id  FROM contacts  LEFT JOIN  accounts_contacts jtl0 ON contacts.id=jtl0.contact_id 
     LEFT JOIN  accounts accounts ON accounts.id=jtl0.account_id AND accounts.deleted=0
     AND accounts.deleted=0 where (( accounts.name IN ( SELECT name FROM accounts accounts_sq_1   LEFT JOIN accounts_cstm accounts_cstm_sq_1 ON accounts_sq_1.id = accounts_cstm_sq_1.id_c   where (accounts_sq_1.industry in ('AnyCompanyName'))  )))  ORDER BY name ASC
    on your sugar instance and post the query time here?

    It´s absolutely puzzling me, it seems a standard query to me, but with ~5.000 records in accounts and contacts each it takes about 120s on all MySQL setups I can get hold of.
    If I add a join on the users table it comes up to 240s.

    If some of you could take the minute and try it on their sugar instance i´d be grateful, just to see if the error is in my MySQL setup or something else.

    Thank you!

    Martin

  2. #2
    madmat is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    Germany
    Posts
    164

    Default Re: SQL Query Benchmark needed!

    P.S.
    The full query, which you are probably unable to process due to the custom fields:
    Code:
    SELECT  contacts.id  ,contacts_cstm.anrede_titel_c,contacts_cstm.erstellt_db_c,contacts_cstm.import_quelle_c,contacts_cstm.pers_funct_c,contacts_cstm.zustand_db_c, CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')) as name, contacts.first_name , contacts.last_name , contacts.salutation  , accounts.name account_name, jtl0.account_id account_id, contacts.phone_work , contacts.assigned_user_id  FROM contacts   LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c   LEFT JOIN  accounts_contacts jtl0 ON contacts.id=jtl0.contact_id  AND jtl0.deleted=0
     LEFT JOIN  accounts accounts ON accounts.id=jtl0.account_id AND accounts.deleted=0
     AND accounts.deleted=0 where (( accounts.name IN ( SELECT name FROM accounts accounts_sq_1   LEFT JOIN accounts_cstm accounts_cstm_sq_1 ON accounts_sq_1.id = accounts_cstm_sq_1.id_c   LEFT JOIN  users jt0 ON jt0.id= accounts_sq_1.assigned_user_id AND jt0.deleted=0  AND jt0.deleted=0 where (accounts_sq_1.industry in ('Apparel')) AND accounts_sq_1.deleted=0 ))) AND contacts.deleted=0 ORDER BY name ASC LIMIT 0,21

  3. #3
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: SQL Query Benchmark needed!

    Hi,

    Try putting some indexing on the fields you are using in 'where' condition.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  4. #4
    agcopley is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Santiago, Chile
    Posts
    204

    Default Re: SQL Query Benchmark needed!

    Run the query directly in mysql using the EXPLAIN statement..you may be surprised.
    Rgds
    Andrew

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 2010-03-23, 11:27 PM
  2. Sugar Benchmark Numbers
    By jbergantzel in forum Installation and Upgrade Help
    Replies: 2
    Last Post: 2009-02-19, 03:07 PM
  3. Replies: 1
    Last Post: 2007-10-12, 09:56 PM
  4. Replies: 2
    Last Post: 2006-10-20, 12:00 AM
  5. How to benchmark a campaign ?
    By manoj in forum Marketing/Campaign Management
    Replies: 2
    Last Post: 2005-10-14, 09:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •