Good tutorial Java programmers to share different optimization methods SQL database

  Good programmers Java tutorial Share SQL database different optimization methods , SQL command because the syntax is simple, efficient operation by a lot of users. However, the efficiency of the SQL command is limited by different database functions, especially in terms of computation time, coupled with the high efficiency of the language does not mean that optimization would be easier, so each database needs to make special adjustments based on the actual situation.

 

  At the same time, which is why we want to understand as much as possible the different ways to optimize or enhance the database to ensure optimal performance reasons. Different positions for developers to optimize SQL database will be different, such as optimizing in some ways will be different with the database administrator (DBA). In large companies, developers and database administrators often need to work together, but in these cases, it is possible conflict between the two teams. All we have to adjust the SQL database in several ways.

 

  1. The appropriate index

 

  Index is essentially a data structure, data retrieval help speed up the whole process. The only index is an index, you can create columns of data that do not overlap. Right index faster access to the database, but not too many indexes or index it will cause bad results, if there is no index, then the process will be very slow.

 

  2. retrieve only relevant data

 

  Specified data to be retrieved accuracy. Use the command * and LIMIT instead of SELECT *, adjusting the database, using data sets need to replace the entire data set is very necessary, especially if your data source is very large, specify the desired use of the data set will save most of the time.

 

  Designating data from the command column, the LIMIT clause can be used to force the SELECT statement returns the specified number of records. Two combinations thereof avoids the problems of future systems, in addition, also to some extent is defined on the reduced data set to further optimize the database.

 

  3. To get rid of the relevant sub-queries

 

  Correlated subquery depends basically on the parent query or outer query. This search is done line by line, which means that it slows down the whole process. Usually if WHERE from the command from the outer query, subquery for each row run, returned by the parent query, thus slowing down the whole process and reduce the efficiency of the database, then the way to better adjust the database is INNERJOIN command. Of course, in some cases, the use of the relevant sub-query is crucial.

 

  The temporary table required to avoid or

 

  If the code can be written in a simple way, never let the temporary tables complicated. Of course, if the data has a specific procedure requiring multiple queries, in this case, it is recommended to use temporary tables. Temporary tables usually alternating sub-queries.

 

  Encoding loop 5. Avoid

 

  Avoid coding cycle is very desirable because it would slow down the entire sequence. By using a unique single row UPDATE or INSERT command to avoid encoding cycle, and to ensure that the stored data is not updated by the WHERE command to find the case of pre-existing data and matching achieved.

 

  6. Implementation Plan

 

  Execution plan optimization tool created by tuning in to play a major role in SQL databases. They also help to create the appropriate index. Although its main function is to graphically display a variety of methods to retrieve the data. But this in turn helps to create the required indexes and perform other necessary steps to optimize the database.

 

  Of course, in addition there are many other ways in an efficient manner to adjust its SQL database.


Guess you like

Origin blog.51cto.com/14573321/2454182