2

我们有一个包含大约 25 列的表,其中包括一个 TXT_SUBSCRIBER_CELL_ID 和 LNGCASE_ID,我们在其上创建了组合索引。

当我们查询

SELECT          LNG_TOWER_ANALYZER_ID,
                LNG_UPLOAD_ID,
                DAT_START,
                ISNULL(LNG_DURATION, 0),
                ISNULL(INT_DIRECTION, 0),
                ISNULL(INT_CALL_DATA_TYPE, 0),
                TXT_SUBSCRIBER_NUMBER,
                TXT_OTHER_PARTY_NUMBER,
                TXT_CALLING_NUMBER,
                TXT_CALLED_NUMBER,
                ISNULL(TXT_SUBSCRIBER_IMSI, ''),
                ISNULL(TXT_SUBSCRIBER_IMEI, ''),
                ISNULL(TXT_SUBSCRIBER_CELL_ID, ''),
                ISNULL(TXT_SUBSCRIBER_BTS_ADDRESS, ''),
                ISNULL(TXT_SUBSCRIBER_LATITUDE, ''),
                ISNULL(TXT_SUBSCRIBER_LONGITUDE, ''),
                ISNULL(TXT_SUBSCRIBER_AZIMUTH_DEG, ''),
                ISNULL(TXT_SUBSCRIBER_NAME, ''),
                ISNULL(TXT_SUBSCRIBER_ADDRESS, ''),
                ISNULL(TXT_SUBSCRIBER_TOC, ''),
                DAT_SUBSCRIBER_ACTIVATION,
                ISNULL(TXT_OTHER_PARTY_NAME, ''),
                ISNULL(TXT_OTHER_PARTY_ADDRESS, ''),
                ISNULL(TXT_OTHER_PARTY_TOC, ''),
                DAT_OTHER_PARTY_ACTIVATION,
                ISNULL(TXT_ROAMING_NETWORK_COMPANY_NAME, ''),
                LNG_CASE_ID,
                ISNULL(TXT_OP_SP_NAME, ''),
                ISNULL(TXT_OP_COUNTRY_NAME, ''),
                ISNULL(TXT_OP_CITY_NAME, ''),
                0,
                ISNULL(BIT_YSN_ROAMING, 0),
                ISNULL(TXT_SUB_SP_NAME, ''),
                ISNULL(TXT_SUB_COUNTRY_NAME, ''),
                ISNULL(TXT_SUB_CITY_NAME, '')
FROM   TBL_TOWER_ANALYZER
WHERE  LNG_CASE_ID = 50
       AND TXT_SUBSCRIBER_CELL_ID IN ( '83_34493', '83_34492', '83_34491', '56_65413',
                                       '56_65412', '56_65411', '56_65364', '56_65363',
                                       '56_65362', '56_65361', '56_65153', '56_65152',
                                       '56_65151', '56_65133', '56_65132', '56_65131',
                                       '56_53013', '56_53012', '56_53011', '56_51463',
                                       '56_51462', '56_51461', '56_51383', '56_51382',
                                       '56_51381', '56_51053', '56_51052', '56_51051',
                                       '56_50193', '56_50192', '56_50191', '56_50053',
                                       '56_50052', '56_50051', '56_46853', '56_46852',
                                       '56_46851', '56_38933', '56_38932', '56_38931',
                                       '56_33703', '56_33702', '56_33701', '56_33473',
                                       '56_33472', '56_33471', '56_32443', '56_32442',
                                       '56_32441', '56_26113', '56_26112', '56_26111',
                                       '56_17143', '56_17142', '56_17141', '56_16803',
                                       '56_16802', '56_16801', '56_16193', '56_16192',
                                       '56_16191', '56_16083', '56_16082', '56_16081',
                                       '56_15533', '56_15532', '56_15531', '56_10284',
                                       '56_10283', '56_10282', '56_10281', '29_51483',
                                       '29_51482', '29_51481', '29_51423', '29_51422',
                                       '29_51421', '29_50943', '29_50942', '29_50941',
                                       '29_50913', '29_50912', '29_50911', '29_50383',
                                       '29_50382', '29_50381', '29_50373', '29_50372',
                                       '29_50371', '29_50343', '29_50342', '29_50341',
                                       '29_50333', '29_50332', '29_50331', '29_50323',
                                       '29_50322', '29_50321', '29_50313', '29_50312',
                                       '29_50311', '29_50303', '29_50302', '29_50301',
                                       '29_50293', '29_50292', '29_50291', '29_50283',
                                       '29_50282', '29_50281', '29_50263', '29_50262',
                                       '29_50261', '29_50253', '29_50252', '29_50251',
                                       '29_50243', '29_50242', '29_50241', '29_50234',
                                       '29_50233', '29_50232', '29_50231', '29_50223',
                                       '29_50222', '29_50221', '29_50203', '29_50202',
                                       '29_50201', '29_43603', '29_43602', '29_43601',
                                       '29_43483', '29_43482', '29_43481', '29_43103',
                                       '29_43102', '29_43101', '29_37203', '29_37202',
                                       '29_37201', '29_37113', '29_37112', '29_37111',
                                       '29_36974', '29_36973', '29_36972', '29_36971',
                                       '29_36964', '29_36963', '29_36962', '29_36961',
                                       '29_34993', '29_34992', '29_34991', '29_34983',
                                       '29_34982', '29_34981', '29_34723', '29_34722',
                                       '29_34721', '29_34483', '29_34482', '29_34481',
                                       '29_33863', '29_33862', '29_33861', '29_33353',
                                       '29_33352', '29_33351', '29_32563', '29_32562',
                                       '29_32561', '29_31633', '29_31632', '29_31631',
                                       '29_28683', '29_28682', '29_28681', '29_27933',
                                       '29_27932', '29_27931', '29_16933', '29_16932',
                                       '29_16931', '29_16773', '29_16772', '29_16771',
                                       '29_13013', '29_13012', '29_13011', '100_57213',
                                       '100_57212', '100_57211', '100_51103', '100_51102',
                                       '100_51101', '100_50986', '100_50985', '100_50984',
                                       '100_50983', '100_50982', '100_50981', '100_50216',
                                       '100_50214', '100_50213', '100_50212', '100_50211',
                                       '100_26223', '100_26222', '100_26221', '100_19823',
                                       '100_19822', '100_19821', '100_18363', '100_18362', '100_18361' )
       AND DAT_START BETWEEN '2013-05-24 01:00:00' AND '2013-05-24 12:59:59' 

完成执行大约需要 50-55 秒,这非常慢。

我们怎样才能让它跑得快。

执行计划

4

2 回答 2

1
  1. 您可以尝试使用索引。

  2. 否则,您可以在 UI 中尝试分页,这将限制要显示的记录数...

于 2013-09-20T07:22:03.167 回答
0
1-) Create a table [Filter_With] with only one field TXT_SUBSCRIBER_CELL_ID
2-) Populate this table with the TXT_SUBSCRIBER_CELL_ID's in the where clause.
3-) Join the Filter_With table with the TBL_TOWER_ANALYZER table.

4-) Define an index for the TXT_SUBSCRIBER_CELL_ID field in the TBL_TOWER_ANALYZER table.
5-) Define an index for the DAT_START field in the TBL_TOWER_ANALYZER.
于 2013-12-21T01:39:41.073 回答