使用查询优化更新用户配置文件字段

时间:2014-06-20 15:45:21

标签: mysql joomla query-optimization inner-join

尝试从导入的用户表中更新Joomla中的某些用户配置文件字段,该表具有特定字段的表查找。寻找一些速度改进,因为我的用户数据库很大,以下查询超时......

    CREATE TABLE joomla.updated_users(UserID varchar(255),Active varchar(255),Absent varchar(255),AllowReconcile varchar(255),Prefix varchar(255),FirstName varchar(255),MiddleName varchar(255),LastName varchar(255),Suffix varchar(255),Email varchar(255),PhoneWork varchar(255),PhoneHome varchar(255),PhoneMobile varchar(255),Fax varchar(255),CountryCode varchar(255),AddressLine1 varchar(255),AddressLine2 varchar(255),MailStop varchar(255),City varchar(255),State varchar(255),PostalCode varchar(255),RequiredApprovals varchar(255),DivisionId varchar(255),OrganizationID varchar(255),LocationID varchar(255),PositionID varchar(255),CostCenterID varchar(255),PartnerType varchar(255),PartnerStatus varchar(255),TrendSegment varchar(255),MonthofService varchar(255),Status varchar(255),Classification varchar(255),LastHireDate varchar(255),OriginalHireDate varchar(255),ApproverID varchar(255),ManagerID varchar(255),Ethnicity varchar(255),Username varchar(255)) CHARACTER SET utf8 COLLATE utf8_general_ci;

    CREATE TABLE joomla.updated_organisation(ID varchar(255),Title varchar(255),ParentID varchar(255),Active varchar(255)) CHARACTER SET utf8 COLLATE utf8_general_ci;

    UPDATE joomla.user_profiles
    INNER JOIN joomla.users ON joomla.users.id = joomla.user_profiles.user_id AND joomla.user_profiles.profile_key = 'organisation'
    INNER JOIN joomla.updated_users ON joomla.updated_users.Email = joomla.users.email
    INNER JOIN joomla.updated_organisation ON joomla.updated_users.OrganizationID = joomla.updated_organisation.ID
    SET joomla.user_profiles.profile_value = joomla.updated_organisation.Title;

提前致谢!

0 个答案:

没有答案