mysql数据库查询优化 mysql效率第1/3页

2019-01-03 14:29:45丽君

       insertbind[1].buffer_type = MYSQL_TYPE_STRING; 
       insertbind[1].buffer_length = ID_LENGTH /* -1 */; 
       insertbind[1].buffer = (char *)m_stInsertParam->channelid; 
       insertbind[1].is_null = 0; 
       insertbind[1].length = 0; 

       insertbind[2].buffer_type = MYSQL_TYPE_TINY; 
       insertbind[2].buffer = (char *)&m_stInsertParam->ISPtype; 
       insertbind[2].is_null = 0; 
       insertbind[2].length = 0; 

       insertbind[3].buffer_type = MYSQL_TYPE_LONG; 
       insertbind[3].buffer = (char *)&m_stInsertParam->externalIP; 
       insertbind[3].is_null = 0; 
       insertbind[3].length = 0; 

       insertbind[4].buffer_type = MYSQL_TYPE_SHORT; 
       insertbind[4].buffer = (char *)&m_stInsertParam->externalPort; 
       insertbind[4].is_null = 0; 
       insertbind[4].length = 0; 

       insertbind[5].buffer_type = MYSQL_TYPE_LONG; 
       insertbind[5].buffer = (char *)&m_stInsertParam->internalIP; 
       insertbind[5].is_null = 0; 
       insertbind[5].length = 0; 

       insertbind[6].buffer_type = MYSQL_TYPE_SHORT; 
       insertbind[6].buffer = (char *)&m_stInsertParam->internalPort; 
       insertbind[6].is_null = 0; 
       insertbind[6].is_null = 0; 
       //绑定 
       if (mysql_stmt_bind_param(m_stInsertStmt, insertbind)) 
              return false; 
       return true; 


//2.查询 
bool CDBManager::InsertHostCache2(MYSQL * connecthandle, char * sessionid, char * channelid, int ISPtype,  
              unsigned int eIP, unsigned short eport, unsigned int iIP, unsigned short iport) 

       //填充结构变量m_sInsertParam 
       strcpy(m_stInsertParam->sessionid, sessionid); 
       strcpy(m_stInsertParam->channelid, channelid); 
       m_stInsertParam->ISPtype = ISPtype; 
       m_stInsertParam->externalIP = eIP; 
       m_stInsertParam->externalPort = eport; 
       m_stInsertParam->internalIP = iIP; 
       m_stInsertParam->internalPort = iport; 
       //执行statement,性能瓶颈处 
       if(mysql_stmt_execute(m_stInsertStmt)) 
              return false; 
       return true;