【开发】SQL优化思路(以oracle为例)
powered by wanglifeng https://www.cnblogs.com/wanglifeng717
单表查询的优化思路
单表查询是最简单也是最重要的模块,它是多表等查询的基础。
避免对数据重复扫描
一次扫描可以获得的数据不应重复扫描。最好不要检查可以通过检查一次数据库来解决的问题。读取数据消耗资源并减少数据块的扫描。
[En]
The data that can be obtained by one scan should not be scanned repeatedly. It is better not to check the problems that can be solved by checking the database once. The reading of data consumes resources and reduces the scanning of data blocks.
例如:
1.SELECT COUNT (*)
FROM employees
WHERE salary < 2000;