亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 1940 | 回復(fù): 0
打印 上一主題 下一主題

sql 多表聯(lián)合查詢優(yōu)化,求思路 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2015-01-20 12:02 |只看該作者 |倒序?yàn)g覽
explain
select sum(ifnull(mb.money,mo.transmoney)) transmoney,mb.mptid,mo.sid
                                        from crm_member_order_history mo
                                        left join crm_combined_bill_history mb on mb.moid = mo.moid
                                        left join alp_member m on m.amid = mo.amid
                                         where mo.type in (1,2,6) and mo.transdate > '2015-01-16 00:00:00'
and mo.transdate < '2015-01-18 23:59:59'  
and mo.sid in (20,24,25,26,27,28,29,30,229,230,300,301,429,452,988,1116,1117,1165,1196,1240,1337 )   
group by mo.sid,mb.mptid;

explain結(jié)果:
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: mo
         type: ALL
possible_keys: crm_member_order_history_alp_shop_FK,idx_type_transdate_sid
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 1
        Extra: Using where; Using temporary; Using filesort
*************************** 2. row ***************************
           id: 1
  select_type: SIMPLE
        table: mb
         type: ref
possible_keys: crm_combined_bill_history_crm_member_order_history_fk
          key: crm_combined_bill_history_crm_member_order_history_fk
      key_len: 4
          ref: alipos.mo.moid
         rows: 1
        Extra: NULL
*************************** 3. row ***************************
           id: 1
  select_type: SIMPLE
        table: m
         type: eq_ref
possible_keys: PRIMARY
          key: PRIMARY
      key_len: 4
          ref: alipos.mo.amid
         rows: 1
        Extra: Using index
3 rows in set (0.00 sec)

-----------------------------------------------------------------------------------------------------------------------------
crm_member_order_history
                            CREATE TABLE `crm_member_order_history` (                                                                                    
                            `moid` int(11) NOT NULL AUTO_INCREMENT,                                                                                    
                            `type` char(5) COLLATE utf8_unicode_ci NOT NULL,                                                                           
                            `operation_type` tinyint(4) NOT NULL,                                                                                       
                            `serialnumber` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,                                                               
                            `transmoney` decimal(10,2) DEFAULT '0.00',                                                                                 
                            `other_pay` decimal(10,2) DEFAULT '0.00',                                                                                   
                            `transcredit` decimal(10,2) DEFAULT '0.00',                                                                                 
                            `presented` decimal(10,2) DEFAULT '0.00',                                                                                   
                            `balance` decimal(10,2) DEFAULT '0.00',                                                                                    
                            `transdate` datetime DEFAULT NULL,                                                                                          
                            `cardcode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,                                                               
                            `cardmbid` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,                                                               
                            `transtatus` tinyint(4) DEFAULT NULL,                                                                                       
                            `muid` int(11) DEFAULT NULL,                                                                                                
                            `sid` int(11) DEFAULT NULL,                                                                                                
                            `maid` int(11) DEFAULT NULL,                                                                                                
                            `srid` int(11) DEFAULT NULL,                                                                                                
                            `ceid` int(11) DEFAULT NULL,                                                                                                
                            `amid` int(11) DEFAULT NULL,                                                                                                
                            `mptid` int(11) DEFAULT NULL,                                                                                               
                            `clearorder` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,                                                                 
                            `clearreason` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,                                                            
                            `cashoid` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,                                                                 
                            `shifttime_dt` datetime DEFAULT NULL,                                                                                       
                            `couponamount` int(11) DEFAULT NULL,                                                                                       
                            `pid` int(11) DEFAULT NULL,                                                                                                
                            `transfernum` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,                                                               
                            `rechargebalance` decimal(10,2) DEFAULT NULL,                                                                              
                            `largessbalance` decimal(10,2) DEFAULT NULL,                                                                                
                            `crid` int(11) DEFAULT NULL,                                                                                                
                            `ifinvoice` tinyint(1) DEFAULT '0',                                                                                         
                            PRIMARY KEY (`moid`),                                                                                                      
                            KEY `crm_member_order_history_alp_member_FK` (`amid`),                                                                     
                            KEY `crm_member_order_history_crm_custrad_entty_FK` (`ceid`),                                                               
                            KEY `crm_member_order_history_crm_sale_rule_FK` (`srid`),                                                                  
                            KEY `crm_member_order_crm_member_account_FK` (`maid`),                                                                     
                            KEY `crm_member_order_history_alp_shop_FK` (`sid`),                                                                        
                            KEY `crm_member_order_history_alp_merchant_user_FK` (`muid`),                                                               
                            KEY `crm_member_order_history_crm_pay_type_FK` (`mptid`),                                                                  
                            KEY `crm_member_order_history_alp_pos_FK` (`pid`),                                                                          
                            KEY `serialnumber` (`serialnumber`),                                                                                       
                            KEY `type` (`type`),                                                                                                        
                            KEY `crm_member_order_history_crm_reason_FK` (`crid`),                                                                     
                            CONSTRAINT `crm_member_order_history_alp_member_FK` FOREIGN KEY (`amid`) REFERENCES `alp_member` (`amid`),                  
                            CONSTRAINT `crm_member_order_history_alp_merchant_user_FK` FOREIGN KEY (`muid`) REFERENCES `alp_merchant_user` (`muid`),   
                            CONSTRAINT `crm_member_order_history_alp_pos_FK` FOREIGN KEY (`pid`) REFERENCES `alp_pos` (`pid`),                          
                            CONSTRAINT `crm_member_order_history_alp_shop_FK` FOREIGN KEY (`sid`) REFERENCES `alp_shop` (`sid`),                        
                            CONSTRAINT `crm_member_order_history_crm_custrad_entty_FK` FOREIGN KEY (`ceid`) REFERENCES `crm_custrad_entty` (`ceid`),   
                            CONSTRAINT `crm_member_order_history_crm_member_account_FK` FOREIGN KEY (`maid`) REFERENCES `crm_member_account` (`maid`),  
                            CONSTRAINT `crm_member_order_history_crm_pay_type_FK` FOREIGN KEY (`mptid`) REFERENCES `crm_pay_type` (`mptid`),            
                            CONSTRAINT `crm_member_order_history_crm_reason_FK` FOREIGN KEY (`crid`) REFERENCES `crm_reason` (`crid`),                  
                            CONSTRAINT `crm_member_order_history_crm_sale_rule_FK` FOREIGN KEY (`srid`) REFERENCES `crm_sale_rule` (`srid`)            
                          ) ENGINE=InnoDB AUTO_INCREMENT=3143172 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci     



您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP