1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

MySQl database slow queries

Discussion in 'Technical chat' started by Tomas139, Oct 21, 2018.

  1. Tomas139

    Tomas139 New Member

    Hello

    I notice in MySQL server log there are slow queries, like

    SELECT tickets.ticketid FROM swtickets AS tickets
    LEFT JOIN swticketlocks AS ticketlocks ON (tickets.ticketid = ticketlocks.ticketid)
    LEFT JOIN swticketwatchers AS ticketwatchers ON (tickets.ticketid = ticketwatchers.ticketid AND ticketwatchers.staffid = '895')
    LEFT JOIN swusers AS users ON (tickets.userid = users.userid)
    LEFT JOIN swusergroups AS usergroups ON (users.usergroupid = usergroups.usergroupid)
    LEFT JOIN swuserorganizations AS userorganizations ON (users.userorganizationid = userorganizations.userorganizationid)
    LEFT JOIN swticketpriorities AS ticketpriorities ON (tickets.priorityid = ticketpriorities.priorityid)
    LEFT JOIN swticketstatus AS ticketstatus ON (tickets.ticketstatusid = ticketstatus.ticketstatusid)
    WHERE tickets.departmentid IN ('239','36','309','30','31','82','35')
    AND tickets.ticketstatusid IN ('227','4','75','108','6','76')
    AND tickets.ownerstaffid IN ('895')
    ORDER BY tickets.lastactivity asc LIMIT 0,150;

    It seems the server dose not use indexes for WHERE conditions
    WHERE tickets.departmentid IN ('239','36','309','30','31','82','35')
    AND tickets.ticketstatusid IN ('227','4','75','108','6','76')
    AND tickets.ownerstaffid IN ('895')

    because of data type difference .

    am I noticed right and if yes, is there workaround to this ?

    Thank you
     
  2. terry wilson

    terry wilson New Member

    You should use the structural command to this rather than simply using joins and indexes. Make an object a view and a class and than call whatever your requirements are.
     

Share This Page