Collection of Factors Affecting Database Query Efficiency

1. Watermark effect. When a database runs for a long time (months, years), after the records in the table are repeatedly modified and deleted, a large amount of disk space is not reclaimed, and the external performance is that the space occupied by the table is getting larger and larger. Symptoms of slow queries occur when a query requires a full table scan.

2. BLOB, CLOB field abuse. There are two tables, one has LOB type columns and the other does not. The number of records is the same, and the indexes are the same, so the query data is the same? The answer is no, even if you do not query the contents of the LOB field, the table with the LOB type will be slower. This was verified in the Taobao team. The solution they used was to put the LOB field separately in another table.


3. Adjust the operating system parameters, for example, the ORACLE database running on the UNIX operating system can adjust the size of the UNIX data buffer pool, the memory size that each process can use, and other parameters.



Other common reasons

1. There is no index or no index is used. A database index is like a directory in a book, so that when users access database data, they can find the data they need without traversing all the data. After the index is created, the uniqueness of each row of data can be guaranteed, which greatly improves the efficiency of data retrieval. This is one way to sacrifice space for performance. The absence or use of no indexes is the most common cause of slow data access and a flaw in programming.

2. The I/O throughput is small, forming a bottleneck effect. The I/O throughput is an objective factor (hardware factor) that affects the data access speed. In a certain hardware environment, the I/O throughput can be appropriately improved by using an optimized deployment scheme.

3. The query is not optimized because the calculated column is not created. The calculated column is a special column. It does not fill in any design type, and the user cannot change the value of the column. The value of a calculated column is the result of calculating the value of another or more columns as input values ​​through a certain function formula, etc. If there is no corresponding calculated column, the existing data needs to be calculated when some data is queried, thus wasting part of the performance.

4. Insufficient memory Query access to database data will undoubtedly occupy a large amount of memory space. When memory is insufficient, the data access speed will be significantly affected or even the access will timeout, which is an objective factor affecting the data access speed. .

5. Slow network speed Slow network speed is an objective factor that affects the speed of data access. It can be solved by increasing the bit width of network access.

6. The amount of data queried is too large When the amount of data queried is too large, the memory usage and system time usage will affect the speed of data access. It can be solved by using multiple queries, positioning queries, and query data volume control.

7. Locks or deadlocks Locks or deadlocks will cause visitors to wait for time or permanently fail to obtain resources when accessing database data. This is one of the most common factors for slow queries, and it is a flaw in program design, which should be avoided as much as possible.

8. Returning unnecessary rows and columns In general data queries, as much data information as possible is obtained, which causes unnecessary data traversal and greatly increases the response time of data access. Therefore, in general queries, try to query as few rows and columns as possible to minimize data traversal time to meet data output requirements.

9. The query statement is not optimized enough In the process of data query access, the most frequently used is the use of custom query statement for data output. Therefore, writing optimized query statements can greatly improve the speed of data query access.
Performance optimization Database performance optimization is mainly to improve the speed of data access, that is, to improve the performance indicators of database response speed. Performance optimization is mainly divided into two parts: subjective factors and objective factors. Here, it is mainly optimized for objective factors that affect performance.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326262235&siteId=291194637