mysql非本地查询特别慢

展开阅读全文

单表SQL查询特别,请问解决方法?

05-26

大约有3500条数据,为建立一个树结构而使用递归函数,函数中有select 语句,但在函数结尾已经关闭SQL连接,不知为什么速度特别慢,大约30秒才能完成。大概代码如下:rnvoid CTreeDataDlg::TreeAddSubTree(CString ParTree, CString strChildTree, HTREEITEM hPartItem)rnrnrnif (strChildTree!="0")rn rnrn _RecordsetPtr m_pTreeRecordset; //用于创建一个查询记录集rn _variant_t vChild;rnrn HTREEITEM hCurrent;rnrn CString strSQL,strCurItem;rnrn strSQL="SELECT * FROM code where ParentItem = '" ;rn strSQL=strSQL+ParTree+"'";rn tryrn rn HRESULT hTRes;rn hTRes = m_pTreeRecordset.CreateInstance(_T("ADODB.Recordset"));rn if (SUCCEEDED(hTRes))rn rn //----------------------------------------------------rn hTRes = m_pTreeRecordset->Open(.....);rn if(SUCCEEDED(hTRes))rn rn TRACE(_T("连接成功!\n"));rn //------------------------------------------rn m_pTreeRecordset->MoveFirst();rn if (!(m_pTreeRecordset->adoEOF))rn rn rn while(!m_pTreeRecordset->adoEOF)rn rn hCurrent = m_ctrlTree.InsertItem(...);rnrn if (TreeSumRecordCount(VariantToCString\rn (m_pTreeRecordset->GetCollect("Name")))>0)rn rn TreeAddSubTree(VariantToCString(m_pTreeRecordset->GetCollect("Name")),rn (VariantToCString(m_pTreeRecordset->GetCollect("Name"))),rn hCurrent);rn rn rn if (!(m_pTreeRecordset->adoEOF))rn rn m_pTreeRecordset->MoveNext();rn rn rn rn //---------------------------------------rn rn rn m_pTreeRecordset->Close();rn m_pTreeRecordset.Release();rn rn catch(_com_error e)///捕捉异常rn rn MessageBox("创建省市记录集失败!");rn rn rn 论坛

Mongodb在 高并发的时候查询特别的问题

05-12

mongodb在访问量大的时候遇到了性能问题。rnrn同样一个查询,在访问量少的时候,100ms就能解决,但是访问量大的时候几十秒都无法查询出来。rnrn当访问量大的时候, db.currentOp(), 会发现数据库里面有非常多的查询等待执行。请看下面的打印日志,发现timeAcquiringMicros的时间特别长,是在等待什么锁吗,动则十秒上百秒的,也不知道是为什么。rnrn我数据库的设计都是按照key value的形式来的,只有一个索引,也只会按照这个索引来查询,没有任何复杂查询,数据库里面也只有添加,删除和查询三种操作。 请各位大神看看,到底是什么引起的这个问题。 数据库里面的记录在百万-千万之间,访问量大的时候每天最多20w pv左右,有可能单位时间的访问量会比较大, cpu和内存也都没有满载rnrn rn "desc" : "conn7006",rn "threadId" : "14028",rn "connectionId" : 7006,rn "client" : "127.0.0.1:58982",rn "active" : true,rn "opid" : 15131018,rn "secs_running" : 0,rn "microsecs_running" : NumberLong(77711),rn "op" : "query",rn "ns" : "SuperMirror_Limited.SuperMirrorSettingCollectionrn",rn "query" : rn "find" : "SuperMirrorSettingCollection",rn "filter" : rn "Key" : "SpidersCacheKey"rn rn ,rn "planSummary" : "IXSCAN Key: 1 ",rn "numYields" : 1,rn "locks" : rn "Global" : "r",rn "Database" : "r"rn ,rn "waitingForLock" : true,rn "lockStats" : rn "Global" : rn "acquireCount" : rn "r" : NumberLong(4)rn rn ,rn "Database" : rn "acquireCount" : rn "r" : NumberLong(2)rn ,rn "acquireWaitCount" : rn "r" : NumberLong(2)rn ,rn "timeAcquiringMicros" : rn "r" : NumberLong(300543)rn rn ,rn "Collection" : rn "acquireCount" : rn "r" : NumberLong(1)rn rn rn 论坛

打印速度特别

02-05

我在程序里面调用了下面函数进行打印,这个过程耽误特别多的时间影响了程序的继续进行。该怎么处理以下呢?rn[code=C/C++]rnvoid COutList::PrintPage()rnrn char szprinter[80];rn char *szDevice,*szDriver,*szOutput;rn HDC hdcprint; // 定义一个设备环境句柄rn //定义一个打印作业rn DOCINFO di=sizeof(DOCINFO),"printer",NULL;rn // 得到设备字符串存入数组szprinter中rn GetProfileString("windows","device",",,,",szprinter,80);rn // 将设备字符串分解rn if(NULL!=(szDevice=strtok(szprinter,","))&&NULL!=(szDriver=strtok(NULL,","))&&NULL!=(szOutput=strtok(NULL,","))) rn rn // 创建一个打印机设备句柄 rn if((hdcprint=CreateDC(szDriver,szDevice,szOutput,NULL))!=0) rn rn CRect rc, rt1, rt2, rt3, rt4, rt5, rt6;rn if(StartDoc(hdcprint,&di)>0) //开始执行一个打印作业 rn rn StartPage(hdcprint); //打印机走纸,开始打印 rn SaveDC(hdcprint); //保存打印机设备句柄 rn //输出内容rn TextOut(hdcprint,250,260,"姓名:张三",10); rn TextOut(hdcprint,900,260,"性别:男",8); rn rn RestoreDC(hdcprint,-1); //恢复打印机设备句柄 rnrn EndPage(hdcprint); //打印机停纸,停止打印 rn EndDoc(hdcprint); //结束一个打印作业 rn //MessageBox("打印完毕!","提示",MB_ICONINFORMATION); rn rn // 用API函数DeleteDC销毁一个打印机设备句柄 rn DeleteDC(hdcprint); rn rn else rn rn MessageBox("没有默认打印机,或者没有安装打印机!"); rn return; rn rn rnrn[/code] 论坛

_RecordsetPtr Requery 特别

10-26

使用Requery (-1)时,特别慢,400条数据居然花了将近10秒钟。rnrn生成RecordsetPtr时的设置rnif (SUCCEEDED(m_record.CreateInstance(__uuidof(Recordset))))rn rn m_record->CursorLocation = adUseClient;rn m_pDBList->GetRecordSet(std::get<1>(m_dbConfig),rn m_record,rn CursorTypeEnum::adOpenForwardOnly);rnrnrnGetRecordSet:rnbool CDBList::GetRecordSet(CString bstrSqlCmd,rn _RecordsetPtr &RecordSet,rn CursorTypeEnum RecordSetType)rnrn long l_statu = m_pConnection->GetState();rnrn if (l_statu != adStateOpen)rn rn return false;rn rn if (bstrSqlCmd.GetLength() < 10)rn rn return false;rn rnrn bool isOK = false;rn int count = 0;rn bool isReconn = false;rn clock_t start = clock();rn while (!isOK)rn rn tryrn rn //打开记录集rn if (FAILED(RecordSet->Open(_bstr_t(bstrSqlCmd),rn m_pConnection.GetInterfacePtr(),rn RecordSetType, adLockOptimistic, adCmdText)))rn rn m_strMsg = _T("查询失败");rn return false;rn rn isOK = true;rn m_strMsg = _T("查询成功");rn rn catch (_com_error e)rn rn rn m_strMsg.Format(_T("获取记录集出现异常,异常信息:%s,异常描述:%s"),rn e.ErrorMessage(), e.Description().GetBSTR());rn //CLog::Write(Error + bstrSqlCmd);rnrn //CVecMsg::AddMsg(tagMsg(Error, eMsgType::MSG_ERROR));rnrn clock_t end = clock();rn double times = (double)(end - start) / CLOCKS_PER_SEC;rn if (isReconn)rn rn m_strMsg = _T("重新连接成功,依然执行失败,放弃执行");rn return false;rn rnrn if (++count >= 3 && times > 6)rn rn m_strMsg = _T("重新执行操作3次,且时间超过6S,重新连接");rnrn count = 0;rn isReconn = ReConn();rn start = clock();rn rn Sleep(200);rnrn isOK = false;rn rn rn return true;rn 论坛

没有更多推荐了,返回首页