Query efficiency has always been a key factor in measuring database performance. With the rapid increase of the total amount of data in the network environment, more stringent requirements are placed on the response time of database queries. Aiming at the current popular open-source database MySQL, this paper analyzes the implementation process of executing SQL query statements and obtains the objective factors that affect the efficiency of query execution. On this basis, several practical and feasible performance optimization methods are proposed. The integrated energy management of collaborative smart buildings is introduced, which can promote the development of the industry.