Skip to content

Commit

Permalink
update sql docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzhao committed Feb 24, 2025
1 parent 5f2a5e2 commit ac8540b
Showing 1 changed file with 64 additions and 1 deletion.
65 changes: 64 additions & 1 deletion docs/optimize/1.overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ TPC-C使用tpmC值(Transactions per Minute)来衡量系统最大有效吞吐



#### 基准测试的性能指标
### 基准测试的性能指标

在衡量一个系统性能时,一定要有可量化的指标,无法量化就无法有效的优化系统性能。系统每秒可以承载多大请求量,每个请求的响应时间,并发数等都是衡量一个系统的关键性能指标。

Expand All @@ -193,6 +193,69 @@ TPC-C使用tpmC值(Transactions per Minute)来衡量系统最大有效吞吐
对于数据库,一次查询、修改、新增、删除。这些我们都可以看作一个事务或者请求。


#### QPS

QPS `Queries Per Second` 是每秒查询率,是一台服务器每秒能够相应的查询次数,是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准, 即每秒的响应请求数,也即是最大吞吐能力。QPS 中的 Q 应该和 SQL 中的 Q 一样,都是广义上的 Query,也就是所有的 `SQL` 语句。


关于这个Q,其实在MySQL上也有两个变量。

```SQL
show global status like 'Que%'
+---------------+------------+
| Variable_name | Value |
+---------------+------------+
| Queries | 6173236173 |
| Questions | 5451023114 |
+---------------+------------+
2 rows in set (0.48 sec)


```



```
Queries
The number of statements executed by the server. This variable includes statements executed within stored programs, unlike the Questions variable. It does not count COM_PING or COM_STATISTICS commands.
The discussion at the beginning of this section indicates how to relate this statement-counting status variable to other such variables.
服务器执行的语句数。此变量包括在存储过程和函数中执行的语句,与Questions变量不同。 它不计算COM_PING或COM_STATISTICS命令
Questions
The number of statements executed by the server. This includes only statements sent to the server by clients and not statements executed within stored programs, unlike the Queries variable. This variable does not count COM_PING, COM_STATISTICS, COM_STMT_PREPARE, COM_STMT_CLOSE, or COM_STMT_RESET commands.
The discussion at the beginning of this section indicates how to relate this statement-counting status variable to other such variables.
服务器执行的语句数。仅包括由客户端发送到服务器的语句,而不包括在存储过程和存储函数中执行的语句,这与Queries变量不同。
此变量不计算COM_PING,COM_STATISTICS,COM_STMT_PREPARE,COM_STMT_CLOSE或COM_STMT_RESET命令
```

从定义上看着Queries是包含存储过程,并且不包含 `com_ping``com_statistics` ,而Questions 则是包含大量Com 操作的。那到底使用那个作为展示的参数? 一般会使用 quersions 的值作为一个监控值,例如pmm 中并没有 queries 而选择显示的是 questions 作为一个数据库执行语句的监控值。




#### TPS

TPS `Transactions Per Second` 也就是事务数/秒


从web应用的角度来说,包括了

1)用户通过client工具,开始发起请求
2)client工具执行N个服务端的API调用
3)client进行API结果的聚合再渲染,最后呈现给用户。

这三个过程组成一个事务,每秒能够完成N事务,Tps也就是N。


**响应时间或延迟**

这个指标用于测试任务所需的整体时间。根据具体的应用,测试的时间单位可能是微秒,毫秒,秒,分钟。
Expand Down

0 comments on commit ac8540b

Please sign in to comment.