生产中遇到一种场景, 生产线上传测试结果的XML文件到数据库, 数据文件大概在7万个字符,保存成文件的大小为70KB左右。
在写入指定的表时, 经常出现系统卡顿, 后台队列等待时间较长的情况。
问题排查一直持续了10小时左右。 有修改测试软件, 有新建保存测试记录的表。 最后选择压缩上传的XML文件进行保存, 解决了这个问题。
DECLARE @XmlData NVARCHAR(MAX); DECLARE @CPSXmlData VARBINARY(MAX); SET @XmlData = ' <Tb_Test_Record> <Tb_Result> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <FatherBarcode /> <BeginDate>2022-04-19 08:13:33</BeginDate> <TestPeriod>161.54</TestPeriod> <EndDate>2022-04-19 08:16:14</EndDate> <UserID>2300078</UserID> <TotalResult>0</TotalResult> <EquipID>1</EquipID> <ManufactureCode>0</ManufactureCode> <TfpID>BOBCal</TfpID> <CreateDate>2022-04-19 08:16:14</CreateDate> <Log /> <WXPOnum>9990089926</WXPOnum> <Insert_Time /> </Tb_Result> <Tb_Item_Result> <ItemResultID>20001</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>信息写入</ItemName> <ItemIndex>1</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:13:33</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:13:33</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30001</DetailResultID> <ItemResultID>20001</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:13:33</BeginDate> <DiffTime>26.00</DiffTime> <EndDate>2022-04-19 08:13:59</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:13:33</CreateDate> <Description>SoftVesion:V1.1.10P7N2,CreateTime:2021-10-12 14:54:45,HardVesion:V1.1.05,MAC1:08:AA:89:88:52:B4,MAC2:08:AA:89:88:52:B5,MAC3:08:AA:89:88:52:B6,MAC4:08:AA:89:88:52:B7,MAC5:08:AA:89:88:52:B8,MAC6:08:AA:89:88:52:B9,GPON SN前缀:ZTEG,GPONSN:CEC1D33A,GPONSNPWD:GCEC1D33A,VoipAgm:4,WEBUSER:user,WEBPASS:user,OUI_START:08AA89,OUI_END:ZTE0QHEN4G00934,SSID1:ZTE_2.4G_7Vujq5,PASSWORD1:4eiCruRU,VoipAgm:4,SSID1_5G:ZTE_5G_7Vujq5,PASSWORD1_5G:4eiCruRU,</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40001</ItemParamID> <DetailResultID>30001</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:13:33</BeginDate> <EndDate>2022-04-19 08:13:59</EndDate> <ParamResType>1</ParamResType> <ParamName>信息写入</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>20002</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>TX校准</ItemName> <ItemIndex>2</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:04</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:04</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30002</DetailResultID> <ItemResultID>20002</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:04</BeginDate> <DiffTime>9.00</DiffTime> <EndDate>2022-04-19 08:15:13</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:04</CreateDate> <Description>,DAC=177,TX光值:2.36</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40002</ItemParamID> <DetailResultID>30002</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:04</BeginDate> <EndDate>2022-04-19 08:15:13</EndDate> <ParamResType>1</ParamResType> <ParamName>TX校准</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>20003</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>TX DDMI</ItemName> <ItemIndex>3</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:13</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:13</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30003</DetailResultID> <ItemResultID>20003</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:13</BeginDate> <DiffTime>4.00</DiffTime> <EndDate>2022-04-19 08:15:17</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:13</CreateDate> <Description>calc1:2997.82353207439</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40003</ItemParamID> <DetailResultID>30003</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:13</BeginDate> <EndDate>2022-04-19 08:15:17</EndDate> <ParamResType>1</ParamResType> <ParamName>TX DDMI</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>20004</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>TX DDMI Test</ItemName> <ItemIndex>4</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:17</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:17</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30004</DetailResultID> <ItemResultID>20004</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:17</BeginDate> <DiffTime>2.00</DiffTime> <EndDate>2022-04-19 08:15:19</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:17</CreateDate> <Description>功率器读取=2.4 dBm,,寄存器读值=2.41172786770047 dBm</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40004</ItemParamID> <DetailResultID>30004</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:17</BeginDate> <EndDate>2022-04-19 08:15:19</EndDate> <ParamResType>1</ParamResType> <ParamName>TX DDMI Test</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>20005</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>消光比校准</ItemName> <ItemIndex>5</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:19</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:19</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30005</DetailResultID> <ItemResultID>20005</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:19</BeginDate> <DiffTime>11.00</DiffTime> <EndDate>2022-04-19 08:15:30</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:19</CreateDate> <Description>13.46 dB</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40005</ItemParamID> <DetailResultID>30005</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:19</BeginDate> <EndDate>2022-04-19 08:15:30</EndDate> <ParamResType>1</ParamResType> <ParamName>消光比校准</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>20006</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>Bias电流测试</ItemName> <ItemIndex>6</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:32</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:32</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30006</DetailResultID> <ItemResultID>20006</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:32</BeginDate> <DiffTime>2.00</DiffTime> <EndDate>2022-04-19 08:15:34</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:32</CreateDate> <Description>MOD_MAX:104,Bias:13.2,Mod:30.4</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40006</ItemParamID> <DetailResultID>30006</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:32</BeginDate> <EndDate>2022-04-19 08:15:34</EndDate> <ParamResType>1</ParamResType> <ParamName>Bias电流测试</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>20007</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>RX DDMI</ItemName> <ItemIndex>7</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:34</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:34</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30007</DetailResultID> <ItemResultID>20007</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:34</BeginDate> <DiffTime>9.00</DiffTime> <EndDate>2022-04-19 08:15:43</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:34</CreateDate> <Description>slopeP1:0.360252827939365,slopeP2:0,offset-4.30767174624793</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40007</ItemParamID> <DetailResultID>30007</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:34</BeginDate> <EndDate>2022-04-19 08:15:43</EndDate> <ParamResType>1</ParamResType> <ParamName>RX DDMI</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>20008</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>RX DDMI Test</ItemName> <ItemIndex>8</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:43</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:43</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30008</DetailResultID> <ItemResultID>20008</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:43</BeginDate> <DiffTime>6.00</DiffTime> <EndDate>2022-04-19 08:15:49</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:43</CreateDate> <Description>RXTestPoint1:-6.96587929403258,RXTestPoint2:-14.9757288001557,RXTestPoint3:-20.0877392430751,RXTestPoint4:-25.2287874528034,RXTestPoint5:-30.4575749056068</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40008</ItemParamID> <DetailResultID>30008</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:43</BeginDate> <EndDate>2022-04-19 08:15:49</EndDate> <ParamResType>1</ParamResType> <ParamName>RX DDMI Test</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>20009</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>LOS Cal</ItemName> <ItemIndex>9</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:49</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:49</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>30009</DetailResultID> <ItemResultID>20009</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:49</BeginDate> <DiffTime>2.00</DiffTime> <EndDate>2022-04-19 08:15:51</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:49</CreateDate> <Description>LosLevel:28</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>40009</ItemParamID> <DetailResultID>30009</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:49</BeginDate> <EndDate>2022-04-19 08:15:51</EndDate> <ParamResType>1</ParamResType> <ParamName>LOS Cal</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>200010</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>LOS测试</ItemName> <ItemIndex>10</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:51</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:51</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>300010</DetailResultID> <ItemResultID>200010</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:51</BeginDate> <DiffTime>2.00</DiffTime> <EndDate>2022-04-19 08:15:53</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:51</CreateDate> <Description>LOS TEST OK</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>400010</ItemParamID> <DetailResultID>300010</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:51</BeginDate> <EndDate>2022-04-19 08:15:53</EndDate> <ParamResType>1</ParamResType> <ParamName>LOS测试</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>200011</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>灵敏度测试</ItemName> <ItemIndex>11</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:15:53</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:15:53</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>300011</DetailResultID> <ItemResultID>200011</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:15:53</BeginDate> <DiffTime>13.00</DiffTime> <EndDate>2022-04-19 08:16:06</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:15:53</CreateDate> <Description>,-28.5</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>400011</ItemParamID> <DetailResultID>300011</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:15:53</BeginDate> <EndDate>2022-04-19 08:16:06</EndDate> <ParamResType>1</ParamResType> <ParamName>灵敏度测试</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>200012</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>上传电压测试</ItemName> <ItemIndex>12</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:16:06</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:16:06</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>300012</DetailResultID> <ItemResultID>200012</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:16:06</BeginDate> <DiffTime>1.00</DiffTime> <EndDate>2022-04-19 08:16:07</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:16:06</CreateDate> <Description>3.2682</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>400012</ItemParamID> <DetailResultID>300012</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:16:06</BeginDate> <EndDate>2022-04-19 08:16:07</EndDate> <ParamResType>1</ParamResType> <ParamName>上传电压测试</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>200013</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>上传温度测试</ItemName> <ItemIndex>13</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:16:07</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:16:07</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>300013</DetailResultID> <ItemResultID>200013</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:16:07</BeginDate> <DiffTime>0.00</DiffTime> <EndDate>2022-04-19 08:16:07</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:16:07</CreateDate> <Description>42.21875 ℃</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>400013</ItemParamID> <DetailResultID>300013</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:16:07</BeginDate> <EndDate>2022-04-19 08:16:07</EndDate> <ParamResType>1</ParamResType> <ParamName>上传温度测试</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> <Tb_Item_Result> <ItemResultID>200014</ItemResultID> <ResultID>10001</ResultID> <Barcode>08AA898852B4</Barcode> <ItemName>写A0信息</ItemName> <ItemIndex>14</ItemIndex> <ItemResult>0</ItemResult> <BeginDate>2022.04.19 08:16:07</BeginDate> <LoopNum>1</LoopNum> <IsChecked>1</IsChecked> <CreateDate>2022.04.19 08:16:07</CreateDate> <Insert_Time /> </Tb_Item_Result> <Tb_Detail_Result> <DetailResultID>300014</DetailResultID> <ItemResultID>200014</ItemResultID> <Barcode>08AA898852B4</Barcode> <LoopID>1</LoopID> <BeginDate>2022.04.19 08:16:07</BeginDate> <DiffTime>3.00</DiffTime> <EndDate>2022-04-19 08:16:10</EndDate> <DetailResult>0</DetailResult> <CreateDate>2022.04.19 08:16:07</CreateDate> <Description>BOSA_SN:GED-C04G3610351C,DataTime:20220419,checksum(0~62):24,checksum(64~94):131,</Description> <Insert_Time /> </Tb_Detail_Result> <Tb_Cfg_Param> <ItemParamID>400014</ItemParamID> <DetailResultID>300014</DetailResultID> <Barcode>08AA898852B4</Barcode> <BeginDate>2022.04.19 08:16:07</BeginDate> <EndDate>2022-04-19 08:16:10</EndDate> <ParamResType>1</ParamResType> <ParamName>写A0信息</ParamName> <ParamRes1>PASS</ParamRes1> <ParamRes2 /> <Insert_Time /> </Tb_Cfg_Param> </Tb_Test_Record>'; -- 把字符串转换成XML格式 SELECT CAST(@XmlData AS XML) AS XMLFmt -- 压缩字符中成 VARBINARY 二进制数据 SELECT @CPSXmlData = COMPRESS(@XmlData); SELECT @CPSXmlData AS CompressData -- 把压缩的字符串解压, 并转换成字符串 SELECT CONVERT(NVARCHAR(MAX), DECOMPRESS(@CPSXmlData)) AS SourceStr