Comments (1)
如何减少CPU消耗
减少等待
减少IO量
-
SQL/index,使用合适的索引减少扫描的行数(需平衡索引的正收益和维护开销,空间换时间)
-
提升IO处理能力
-
加cache/加磁盘/SSD
减少计算
减少逻辑运算量
-
避免使用函数,将运算转移至易扩展的应用服务器中 如substr等字符运算,dateadd/datesub等日期运算,abs等数学函数
-
减少排序,利用索引取得有序数据或避免不必要排序 如union all代替 union,order by 索引字段等
-
禁止类型转换,使用合适类型并保证传入参数类型与数据库字段类型绝对一致 如数字用tiny/int/bigint等,必需转换的在传入数据库之前在应用中转好
-
简单类型,尽量避免复杂类型,降低由于复杂类型带来的附加运算。更小的数据类型占用更少的磁盘、内存、cpu缓存和cpu周期
减少逻辑IO量
-
index,优化索引,减少不必要的表扫描 如增加索引,调整组合索引字段顺序,去除选择性很差的索引字段等等
-
table,合理拆分,适度冗余 如将很少使用的大字段拆分到独立表,非常频繁的小字段冗余到“引用表”
-
SQL,调整SQL写法,充分利用现有索引,避免不必要的扫描,排序及其他操作 如减少复杂join,减少order by,尽量union all,避免子查询等
-
数据类型,够用就好,减少不必要使用大字段 如tinyint够用就别总是int,int够用也别老bigint,date够用也别总是timestamp
减少query请求量(非数据库本身)
-
适当缓存,降低缓存数据粒度,对静态并被频繁请求的数据进行适当的缓存 如用户信息,商品信息等
-
优化实现,尽量去除不必要的重复请求 如禁止同一页面多次重复请求相同数据的问题,通过跨页面参数传递减少访问等
-
合理需求,评估需求产出比,对产出比极端底下的需求合理去除
升级cpu
-
低延迟(快速响应),需要更快的cpu(每个查询只能使用一个cpu)
-
高吞吐,同时运行很多查询语句,能从多个cpu处理查询中收益
from news.
Related Issues (20)
- 备稿计划: 使用 AbortSignal 而非 Promise.race() 做 fetch 超时
- 备稿计划: 解决 BigInt JSON 化问题
- 备稿计划: Deno.run 的局限
- 备稿计划: 在 input 中使用 `type="text" inputmode="numeric"` 替代 `type="number"`
- 备稿计划: `===` 与 `==` 的区别及使用
- 备稿计划: 我对 低代码 的看法
- 备稿计划: Node.js v19 正式发布
- 备稿计划: 工作时长与项目进度
- 备稿计划: 试用 ChatGPT
- 备稿计划: 为什么 TS 要求 ArrayBuffer 类型, 却允许传入 Uint8Array 类型
- 备稿计划: Google 提供的字体特效
- 备稿计划: Deno 现在怎么样 (2023)
- 备稿计划: macOS 自带的 Voice Memos 录音软件
- 备稿计划: Sam Altman 被罢免事件
- 备稿计划: eno1 和 eth0 有什么区别?
- 备稿计划: Rust 的社区治理
- 备稿计划: Flutter HOT 2
- 百度云加速关闭服务
- 飞书调整价格
- 备稿计划: scroll-driven animations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from news.