MySQL慢SQL優化思路

MySQL慢SQL優化思路

具體思路:

1、慢查詢日志記錄慢 SQL

2、explain 分析 SQL 的執行計劃

3、profile 分析執行耗時

4、Optimizer Trace 分析詳情

5、確定問題并采用相應的措施

1、查看慢日志

1.1 使用命令查詢慢日志配置

mysql> show variables like 'slow_query_log%';
+---------------------+---------------------------------------------------------------------+
| Variable_name       | Value                                                               |
+---------------------+---------------------------------------------------------------------+
| slow_query_log      | OFF                                                                 |
| slow_query_log_file | C:\ProgramData\MySQL\MySQL Server 5.5\Data\DESKTOP-CR3IL33-slow.log |
+---------------------+---------------------------------------------------------------------+
2 rows in set (0.00 sec)
  • slow_query_log:表示慢查詢開啟的狀態。
  • slow_query_log_file:表示慢查詢日志存放的位置。

1.2 使用命令查看超過多少時間才記錄到慢查詢日志

mysql> show variables like 'long_query_time';
+-----------------+-----------+
| Variable_name   | Value     |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
1 row in set (0.00 sec)
  • long_query_time:表示查詢超過多少秒才記錄到慢查詢日志。

1.3 查看是否開啟記錄未使用索引sql慢查詢日志

-- 默認是關閉的
mysql> show variables like 'log_queries_not_using_indexes';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| log_queries_not_using_indexes | OFF   |
+-------------------------------+-------+
1 row in set (0.00 sec)

1.4 啟用慢日志

-- 啟用慢查詢,加上global,不然會報錯的
mysql> set global slow_query_log='ON';
Query OK, 0 rows affected (0.01 sec)
-- 是否開啟慢查詢
mysql> show variables like 'slow_query_log%';
+---------------------+---------------------------------------------------------------------+
| Variable_name       | Value                                                               |
+---------------------+---------------------------------------------------------------------+
| slow_query_log      | ON                                                                  |
| slow_query_log_file | C:\ProgramData\MySQL\MySQL Server 5.5\Data\DESKTOP-CR3IL33-slow.log |
+---------------------+---------------------------------------------------------------------+
2 rows in set (0.00 sec)

1.5 修改慢查詢時間

-- 修改慢查詢時間
mysql> set global long_query_time=2;
Query OK, 0 rows affected (0.00 sec)
-- 查看慢查詢時間閾值
mysql> show variables like 'long_query_time';
+-----------------+----------+
| Variable_name   | Value    |
+-----------------+----------+
| long_query_time | 2.000000 |
+-----------------+----------+
1 row in set (0.00 sec)-- 修改了慢查詢日志馬上用上述命令查看發現不生效,其實已經修改成功,可以用下面的命令
mysql> show global variables like 'long_query_time';
+-----------------+----------+
| Variable_name   | Value    |
+-----------------+----------+
| long_query_time | 2.000000 |
+-----------------+----------+
1 row in set (0.00 sec)

1.6 開啟記錄未使用索引sql慢查詢日志

-- 開啟
mysql> set global log_queries_not_using_indexes=1;
Query OK, 0 rows affected (0.00 sec)
-- 查詢
mysql> show variables like 'log_queries_not_using_indexes';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| log_queries_not_using_indexes | ON    |
+-------------------------------+-------+
1 row in set (0.00 sec)

1.7 永久生效

上面的操作并不是永久開啟慢查詢日志,如果要永久生效,就必須修改配置文件 my.cnfmy.ini,在該文件

中,找到或在 [mysqld] 部分下添加以下內容,然后保存文件并重啟 MySQL 服務。

# 開啟慢查詢日志
slow_query_log=1# 指定慢查詢日志生成文件所在路徑
slow_query_log_file=D:\OwnerSoftwareInstall\MySQL\zsx-slow.log# 設置慢查詢時間閾值
long_query_time=2# 開啟記錄未使用索引sql慢查詢日志
log_queries_not_using_indexes=1# 日志輸出方式為文件
log_output=FILE
-- 查看
mysql> show variables like 'slow_query_log%';
+---------------------+--------------------------------------------+
| Variable_name       | Value                                      |
+---------------------+--------------------------------------------+
| slow_query_log      | ON                                         |
| slow_query_log_file | D:\OwnerSoftwareInstall\MySQL\zsx-slow.log |
+---------------------+--------------------------------------------+
2 rows in set (0.00 sec)

1.8 定位慢查詢

看看mysql從啟動到現在,mysql數據庫的一些運行狀態:

mysql> flush status;
Query OK, 0 rows affected (0.00 sec)
-- 從啟動到現在執行select次數
mysql> show global status like 'com_select';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select    | 3     |
+---------------+-------+
1 row in set (0.00 sec)
-- 當前session里執行select次數,session可以不加
mysql> show session status like 'com_select';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select    | 1     |
+---------------+-------+
1 row in set (0.00 sec)
-- 從啟動到現在執行update次數
mysql> show global status like 'com_update';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_update    | 0     |
+---------------+-------+
1 row in set (0.00 sec)
-- 當前session里執行update次數,session可以不加
mysql> show session status like 'com_update';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_update    | 0     |
+---------------+-------+
1 row in set (0.00 sec)
-- 從啟動到現在執行delete次數
mysql> show global status like 'com_delete';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_delete    | 0     |
+---------------+-------+
1 row in set (0.00 sec)
-- 當前session里執行delete次數,session可以不加
mysql> show session status like 'com_delete';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_delete    | 0     |
+---------------+-------+
1 row in set (0.00 sec)
-- 從開啟慢查詢日志開始到現在有多少條慢查詢記錄
mysql> show global status like '%slow_queries%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Slow_queries  | 1     |
+---------------+-------+
1 row in set (0.00 sec)

1.9 使用mysqldumpslow工具分析慢查詢

日志分析工具mysqldumpslow,mysql官方自帶的,只要安裝了mysql就可以使用它,可以用來幫助我們分析慢

日志文件。

# 指定慢查詢日志進行分析
# 查詢執行時間最長的前10
$ perl mysqldumpslow.pl -s t -a -t 10 D:\OwnerSoftwareInstall\MySQL\zsx-slow.log

在這里插入圖片描述

$ perl mysqldumpslow.pl --help
Locale 'Chinese (Simplified)_China.936' is unsupported, and may crash the interpreter.
Usage: mysqldumpslow [ OPTS... ] [ LOGS... ]Parse and summarize the MySQL slow query log. Options are--verbose    verbose--debug      debug--help       write this text to standard output-v           verbose-d           debug-s ORDER     what to sort by (al, at, ar, c, l, r, t), 'at' is defaultal: average lock timear: average rows sentat: average query timec: countl: lock timer: rows sentt: query time-r           reverse the sort order (largest last instead of first)-t NUM       just show the top n queries-a           don't abstract all numbers to N and strings to 'S'-n NUM       abstract numbers with at least n digits within names-g PATTERN   grep: only consider stmts that include this string-h HOSTNAME  hostname of db server for *-slow.log filename (can be wildcard),default is '*', i.e. match all-i NAME      name of server instance (if using mysql.server startup script)-l           don't subtract lock time from total time
參數選項使用說明
-a顯示具體的數字和字符信息,而不是用N或者S代替
-n將數字抽象顯示為指定的數字個數
–debug | -d指定debug模式運行
-g指定大小寫不敏感的正則表達
–help顯示幫助信息
-h指定MySQL主機名稱用于選擇慢查詢日志
-i指定服務器示例名稱用于選擇慢查詢日志
-l顯示總時間(包括lock鎖定時間)
-r逆序排序
-s指定排序方式
-t只顯示指定數量的結果內容
–verbose | -vVerbose模式

使用-s指定排序方式,主要有如下四種方式:

  • l: 按鎖定時間排序
  • r: 按結果行數排序
  • t: 按查詢時間排序
  • c:按執行次數排序

a為平均,與上述參數結合可形成新的排序方式:

  • at:按平均查詢時間排序(默認排序方式)
  • al:按平均鎖定時間排序
  • ar:按平均結果行數排序
# 返回執行次數最高的前10條sql
$ perl mysqldumpslow.pl -s c -a -t 10 D:\OwnerSoftwareInstall\MySQL\zsx-slow.log# 返回結果行數最多的前10條sql
$ perl mysqldumpslow.pl -s r -a -t 10 D:\OwnerSoftwareInstall\MySQL\zsx-slow.log# 返回執行時間最長的前10條sql
$ perl mysqldumpslow.pl -s t -a -t 10 D:\OwnerSoftwareInstall\MySQL\zsx-slow.log

分析后結果參數解讀

  • Count:代表這個 SQL 語句執行了多少次
  • Time:代表執行的時間,括號是累計時間
  • Lock:表示鎖定的時間,括號是累計時間
  • Rows:表示返回的記錄數,括號是累計記錄數

2、explain 分析 SQL 的執行計劃

mysql> explain select * from student;
+----+-------------+---------+------+---------------+------+---------+------+------+-------+
| id | select_type | table   | type | possible_keys | key  | key_len | ref  | rows | Extra |
+----+-------------+---------+------+---------------+------+---------+------+------+-------+
|  1 | SIMPLE      | student | ALL  | NULL          | NULL | NULL    | NULL |    7 |       |
+----+-------------+---------+------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)

type=all 代表進行了全表掃描。

3、show profile分析

了解SQL執行的線程的狀態及消耗的時間。

profiling 默認是關閉,我們可以使用命令查看是否開啟:

-- 未開啟
mysql> show variables like '%profil%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| have_profiling         | YES   |
| profiling              | OFF   |
| profiling_history_size | 15    |
+------------------------+-------+
3 rows in set (0.00 sec)-- 開啟
mysql> show variables like '%profil%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| have_profiling         | YES   |
| profiling              | ON    |
| profiling_history_size | 15    |
+------------------------+-------+
3 rows in set (0.00 sec)
-- 默認是關閉的,開啟語句set profiling = 1;也可以使用set profiling=ON;開啟
mysql> set profiling =1;
Query OK, 0 rows affected (0.00 sec)-- 執行SQL
mysql> select * from student;
+----+-------+
| id | name  |
+----+-------+
|  1 | John  |
|  2 | tom   |
|  3 | marry |
|  6 | marry |
|  7 | tom   |
| 10 | marry |
| 11 | tom   |
+----+-------+
7 rows in set (0.00 sec)-- 可以看到實際的執行語句
mysql> show profiles;
+----------+------------+-----------------------+
| Query_ID | Duration   | Query                 |
+----------+------------+-----------------------+
|        1 | 0.00017550 | select * from student |
+----------+------------+-----------------------+
1 row in set (0.00 sec)

show profiles 會顯示最近發給服務器的多條語句,條數由變量 profiling_history_size 定義,默認是15。

如果我們需要看單獨某條SQL的分析,可以show profile查看最近一條SQL的分析,也可以使用show profile

for query id(其中id就是show profiles中的QUERY_ID)查看具體一條的SQL語句分析。

mysql> show profiles;
+----------+------------+-----------------------+
| Query_ID | Duration   | Query                 |
+----------+------------+-----------------------+
|        1 | 0.00017550 | select * from student |
+----------+------------+-----------------------+
1 row in set (0.00 sec)
mysql> show profile for query 1;
+----------------------+----------+
| Status               | Duration |
+----------------------+----------+
| starting             | 0.000024 |
| checking permissions | 0.000003 |
| Opening tables       | 0.000015 |
| System lock          | 0.000004 |
| init                 | 0.000008 |
| optimizing           | 0.000002 |
| statistics           | 0.000005 |
| preparing            | 0.000004 |
| executing            | 0.000001 |
| Sending data         | 0.000033 |
| end                  | 0.000002 |
| query end            | 0.000002 |
| closing tables       | 0.000003 |
| freeing items        | 0.000025 |
| logging slow query   | 0.000001 |
| logging slow query   | 0.000044 |
| cleaning up          | 0.000002 |
+----------------------+----------+
17 rows in set (0.00 sec)

除了查看 profile ,還可以查看 cpu 和 io:

mysql> show profile cpu,block io for query 1;
+----------------------+----------+----------+------------+--------------+---------------+
| Status               | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+----------------------+----------+----------+------------+--------------+---------------+
| starting             | 0.000024 | 0.000000 |   0.000000 |         NULL |          NULL |
| checking permissions | 0.000003 | 0.000000 |   0.000000 |         NULL |          NULL |
| Opening tables       | 0.000015 | 0.000000 |   0.000000 |         NULL |          NULL |
| System lock          | 0.000004 | 0.000000 |   0.000000 |         NULL |          NULL |
| init                 | 0.000008 | 0.000000 |   0.000000 |         NULL |          NULL |
| optimizing           | 0.000002 | 0.000000 |   0.000000 |         NULL |          NULL |
| statistics           | 0.000005 | 0.000000 |   0.000000 |         NULL |          NULL |
| preparing            | 0.000004 | 0.000000 |   0.000000 |         NULL |          NULL |
| executing            | 0.000001 | 0.000000 |   0.000000 |         NULL |          NULL |
| Sending data         | 0.000033 | 0.000000 |   0.000000 |         NULL |          NULL |
| end                  | 0.000002 | 0.000000 |   0.000000 |         NULL |          NULL |
| query end            | 0.000002 | 0.000000 |   0.000000 |         NULL |          NULL |
| closing tables       | 0.000003 | 0.000000 |   0.000000 |         NULL |          NULL |
| freeing items        | 0.000025 | 0.000000 |   0.000000 |         NULL |          NULL |
| logging slow query   | 0.000001 | 0.000000 |   0.000000 |         NULL |          NULL |
| logging slow query   | 0.000044 | 0.000000 |   0.000000 |         NULL |          NULL |
| cleaning up          | 0.000002 | 0.000000 |   0.000000 |         NULL |          NULL |
+----------------------+----------+----------+------------+--------------+---------------+
17 rows in set (0.00 sec)

4、Optimizer Trace分析詳情(mysql 5.6 及以上版本)

profile 只能查看到 SQL 的執行耗時,但是無法看到 SQL 真正執行的過程信息,即不知道 MySQL 優化器是如何選

擇執行計劃。這時候,我們可以使用Optimizer Trace,它可以跟蹤執行語句的解析優化執行的全過程。

-- 第一步打開trace,設置格式為JSON格式
mysql> set session optimizer_trace="enabled=on",end_markers_in_json=ON;
Query OK, 0 rows affected (0.00 sec)-- 設置優化器跟蹤使用的最大內存量
mysql> set session optimizer_trace_max_mem_size=1000000;
Query OK, 0 rows affected (0.00 sec)-- 查看
mysql> show session variables like 'optimizer_trace';
+-----------------+-------------------------+
| Variable_name   | Value                   |
+-----------------+-------------------------+
| optimizer_trace | enabled=on,one_line=off |
+-----------------+-------------------------+
1 row in set (0.00 sec)
-- 第二步,執行要分析的sql語句
mysql> select * from student;
+----+-------+
| id | name  |
+----+-------+
|  1 | John  |
|  2 | tom   |
|  3 | marry |
|  6 | marry |
|  7 | tom   |
| 10 | marry |
| 11 | tom   |
+----+-------+
7 rows in set (0.00 sec)
-- 第三步,查看information_schema.OPTIMIZER_TRACE,查看sql語句執行跟蹤記錄
mysql> select * from information_schema.optimizer_trace;
+-----------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+-------------------------+
| QUERY                 | TRACE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | MISSING_BYTES_BEYOND_MAX_MEM_SIZE | INSUFFICIENT_PRIVILEGES |
+-----------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+-------------------------+
| select * from student | {"steps": [{"join_preparation": {"select#": 1,"steps": [{"expanded_query": "/* select#1 */ select `student`.`id` AS `id`,`student`.`name` AS `name` from `student`"}] /* steps */} /* join_preparation */},{"join_optimization": {"select#": 1,"steps": [{"table_dependencies": [{"table": "`student`","row_may_be_null": false,"map_bit": 0,"depends_on_map_bits": [] /* depends_on_map_bits */}] /* table_dependencies */},{"rows_estimation": [{"table": "`student`","table_scan": {"rows": 7,"cost": 0.25} /* table_scan */}] /* rows_estimation */},{"considered_execution_plans": [{"plan_prefix": [] /* plan_prefix */,"table": "`student`","best_access_path": {"considered_access_paths": [{"rows_to_scan": 7,"access_type": "scan","resulting_rows": 7,"cost": 0.95,"chosen": true}] /* considered_access_paths */} /* best_access_path */,"condition_filtering_pct": 100,"rows_for_plan": 7,"cost_for_plan": 0.95,"chosen": true}] /* considered_execution_plans */},{"attaching_conditions_to_tables": {"original_condition": null,"attached_conditions_computation": [] /* attached_conditions_computation */,"attached_conditions_summary": [{"table": "`student`","attached": null}] /* attached_conditions_summary */} /* attaching_conditions_to_tables */},{"finalizing_table_conditions": [] /* finalizing_table_conditions */},{"refine_plan": [{"table": "`student`"}] /* refine_plan */}] /* steps */} /* join_optimization */},{"join_execution": {"select#": 1,"steps": [] /* steps */} /* join_execution */}] /* steps */
} |                                 0 |                       0 |
+-----------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+-------------------------+
1 row in set (0.00 sec)
-- 第四步,關閉trace。
mysql> set session optimizer_trace="enabled=off";
Query OK, 0 rows affected (0.00 sec)-- 查看
mysql> show session variables like 'optimizer_trace';
+-----------------+--------------------------+
| Variable_name   | Value                    |
+-----------------+--------------------------+
| optimizer_trace | enabled=off,one_line=off |
+-----------------+--------------------------+
1 row in set (0.00 sec)

可以查看分析其執行樹,會包括三個階段:

  • join_preparation:準備階段
  • join_optimization:分析階段
  • join_execution:執行階段

5、確定問題并采用相應的措施

根據上面4個步驟的分析結果進行相應的優化。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/215331.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/215331.shtml
英文地址,請注明出處:http://en.pswp.cn/news/215331.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mysql 5.7.34升級到5.7.44修補漏洞

mysql 5.7.34舊版本,漏掃有漏洞,升級到最新版本 舊版本5.7.34在 /home/mysql/mysql中安裝 備份舊版本數據還有目錄 數據庫備份升級 tar -xf mysql-5.7.44-el7-x86_64.tar #覆蓋舊版本數據庫文件 #注意看看文件是否和你起服務的用戶一樣 \cp -r mysql-5…

decomposition-based multi-objective algorithm4SPDPTW

關鍵詞 文章概述 研究背景 多目標選擇性接送和配送問題(PDPs):研究涉及多目標選擇性接送和配送問題,這些問題傳統上從單一目標角度進行探討,以尋找最具盈利性的請求集合,同時遵守一系列限制條件。 經濟和…

基于OpenCV+CNN+IOT+微信小程序智能果實采摘指導系統——深度學習算法應用(含python、JS工程源碼)+數據集+模型(五)

目錄 前言總體設計系統整體結構圖系統流程圖 運行環境Python環境TensorFlow 環境Jupyter Notebook環境Pycharm 環境微信開發者工具OneNET云平臺 模塊實現1. 數據預處理2. 創建模型并編譯3. 模型訓練及保存4. 上傳結果5. 小程序開發1)查詢圖片2)查詢識別結…

?os.path --- 常用路徑操作?

源代碼: Lib/posixpath.py (用于 POSIX) 和 Lib/ntpath.py (用于 Windows)。 此模塊實現了一些有用的路徑名稱相關函數。 要讀取或寫入文件請參見 open(),對于訪問文件系統請參閱 os 模塊。 傳給 path 形參的可以是字符串、字節串或者任何實現了 os.PathLike 協議的…

【收獲】成長之路

目錄 一、前言二、計算機方面三、專業知識方面四、總結 一、前言 四年,對于一個人的成長來說,是一個相當重要的階段。在這段時間里,我經歷了許多挑戰、收獲了許多成就,也在不斷地成長和改變。回首這四年的點點滴滴,我深…

hasattr( )函數的用法

hasattr() 函數用于檢查一個對象是否具有指定的屬性或方法, 它接受兩個參數:對象和屬性名(或方法名) 函數語法如下: hasattr(object, attribute)參數說明: object:要檢查的對象attribute&…

前端Vue面試題總結

1,Vue組件的生命周期有哪些,它們的執行順序是什么? Vue組件的生命周期包括beforeCreate、created、beforeMount、mounted、beforeUpdate、updated、beforeDestroy和destroyed等。它們的執行順序如下:beforeCreate -> created -> beforeMount -> mounted -> be…

安裝LLaMA-Factory微調chatglm3,修改自我認知

安裝git clone https://github.com/hiyouga/LLaMA-Factory.git conda create -n llama_factory python3.10 conda activate llama_factory cd LLaMA-Factory pip install -r requirements.txt 之后運行 CUDA_VISIBLE_DEVICES0 python src/train_web.py,按如下配置…

市場全局復盤 20231211

昨日回顧: SELECT TOP 10000 CODE,成交額排名,凈流入排名,代碼,名稱,DDE大單金額,漲幅,所屬行業,主力凈額,DDE大單凈量,CONVERT(DATETIME, 最后漲停時間, 120) AS 最后漲停時間 FROM dbo.全部A股20231208_ALL WHERE 連板天 > 1AND DDE大單凈量 > …

什么是零拷貝

什么是零拷貝? 快速理解 快速理解 要想理解零拷貝,首先要了解操作系統的IO流程,因為有內核態和用戶態的區別,為了保證安全性和緩存,普通的讀寫流程如下: (對于Java程序而言,還會多了一個堆外內…

Windwos server 服務器 安全基線 安全加固操作

目錄 賬號管理、認證授權 賬號 ELK-Windows-01-01-01 ELK-Windows-01-01-02 ELK-Windows-01-01-03 口令 ELK-Windows-01-02-01 ???????ELK-Windows-01-02-02 ???????授權 ELK-Windows-01-03-01 ???????ELK-Windows-01-03-02 ???????ELK-Win…

【LeeCode】54. 替換數字

題目描述 給定一個字符串 s,它包含小寫字母和數字字符,請編寫一個函數,將字符串中的字母字符保持不變,而將每個數字字符替換為number。 例如,對于輸入字符串 "a1b2c3",函數應該將其轉換為 "…

java的long類型超過9位報錯:the literal 987654321000 of type int is out of range

java的long類型超過9位報錯 1、報錯提示2、報錯截圖3、解決辦法4、參考文章 1、報錯提示 the literal 987654321000 of type int is out of range 2、報錯截圖 3、解決辦法 long類型是一種用于表示較大整數的數據類型,范圍比int類型更廣泛。然而,即使…

用PHP和HTML做登錄注冊操作數據庫Mysql

用PHP和HTML做登錄注冊操作數據庫Mysql 兩個HTML頁面&#xff0c;兩個PHP,兩個css,兩張圖片&#xff0c;源碼資源在上方。 目錄 HTML頁面 login.html <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta nam…

IDEA卡頓,進行性能優化設置(親測有效)——情況二

問題背景與現象 IDEA今天突然顯示到期&#xff0c;于是從同事那邊搞到一個很好用的破解方式&#xff0c;說實話&#xff0c;非常方便&#xff08;后續在安前碼后中分享&#xff09; 破解之后呢&#xff0c;香了一陣子&#xff0c;但是突然顯示開始卡頓&#xff0c;界面幾乎是…

【spring boot】RestTemplate 鏈接帶簽名post請求 400 bad request

由于項目需要從服務端對第三方發起請求&#xff0c;而且第三方沒有提供SDK的情況下&#xff0c;只能根據對方api文檔發送請求了&#xff0c;對方接口的格式是&#xff1a;地址簽名&#xff0c;post請求上送具體參數的方式去請求對方服務。 背景 很簡單的一個需求&#xff0c;然…

Word插件-好用的插件-PPT 素材該怎么積累-大珩助手

PPT 素材該怎么積累&#xff1f; 使用大珩助手中的素材庫功能&#xff0c;將Word中的&#xff0c;或系統中的文本文件、圖片、其他word文檔、pdf&#xff0c;所有見到的好素材&#xff0c;一鍵收納。 步驟&#xff1a;選中文件&#xff0c;按住鼠標左鍵拖到素材庫界面中&…

React-router-dom v6和 v5版本“注冊路由”的差異化

React-router-dom v6和 v5版本“注冊路由”的差異化 Matched leaf route at location “/about” does not have an element. This means it will render an with a null value by default resulting in an “empty” page. v6版本中Switch已經被換成了Routes&#xff0c;點擊鏈…

【軟考】信息系統項目管理師論文方向猜想

報喜不報憂&#xff0c;每天都在為雞零狗碎推諉扯皮&#xff0c;屬實是有辱師門。 通過軟考&#xff0c;目前算是真正有意義的事情。 雖然都說高項的論文是個玄學&#xff0c;但是道聽途說了一些通關感想還是蠻有啟發的。 文件要求 參考了一份廣西省高級工程師評審的文件&am…

Leetcode704二分查找、折半查找(Java實現)

好久沒有更新算法題&#xff0c;今天來寫一道二分查找的題目。題目要求如下&#xff0c; 那么這道題的解題思路如下&#xff0c;我們尋找的過程是首先去訪問數組的中間位置mid&#xff0c;如果nums[mid]大于了targe那么說明&#xff0c;我們要找的數在mid的左半邊&#xff0c;…