MySQL 8.0 Reference Manual(讀書筆記45節--Optimization Overview)

来源:https://www.cnblogs.com/xuliuzai/p/18190173
-Advertisement-
Play Games

問題現象 ps -ef | grep yas 查看無yasom和yasagent進程,且在{資料庫安裝目錄}/om/{資料庫名稱}的目錄下沒有conf、data、log等目錄,確定資料庫不是用yasboot安裝,是用腳本安裝的 問題的風險及影響 非yasboot安裝,ycm無法完成托管,無法監控 問 ...


Optimization involves【ɪnˈvɑːlvz 需要;影響;(使)參加,加入;包含;牽涉;牽連;使成為必然部分(或結果);】 configuring, tuning, and measuring performance, at several levels. Depending on your job role (developer, DBA, or a combination of both), you might optimize at the level of individual【ˌɪndɪˈvɪdʒuəl 單獨的;個別的;獨特的;一個人的;與眾不同的;】 SQL statements, entire applications, a single database server, or multiple networked database servers. Sometimes you can be proactive【ˌproʊˈæktɪv 積極主動的;先發制人的;主動出擊的;】 and plan in advance for performance, while other times you might troubleshoot a configuration or code issue after a problem occurs. Optimizing CPU and memory usage can also improve scalability【skeɪləˈbɪlɪti 可擴展性;可伸縮性;可量測性;】, allowing the database to handle more load without slowing down.

Optimization Overview

Database performance depends on several factors at the database level, such as tables, queries, and configuration settings. These software constructs result in CPU and I/O operations at the hardware level, which you must minimize and make as efficient as possible. As you work on database performance, you start by learning the high-level rules and guidelines for the software side, and measuring performance using wall-clock time. As you become an expert, you learn more about what happens internally, and start measuring things such as CPU cycles and I/O operations.

Typical users aim to get the best database performance out of their existing software and hardware configurations. Advanced users look for opportunities to improve the MySQL software itself, or develop their own storage engines and hardware appliances to expand the MySQL ecosystem【ˈiːkoʊsɪstəm 生態系統;】.

1.Optimizing at the Database Level

The most important factor in making a database application fast is its basic design:

• Are the tables structured properly? In particular, do the columns have the right data types, and does each table have the appropriate columns for the type of work? For example, applications that perform frequent updates often have many tables with few columns, while applications that analyze large amounts of data often have few tables with many columns.

• Are the right indexes in place to make queries efficient?

• Are you using the appropriate storage engine for each table, and taking advantage of the strengths and features of each storage engine you use? In particular, the choice of a transactional storage engine such as InnoDB or a nontransactional one such as MyISAM can be very important for performance and scalability【skeɪləˈbɪlɪti 可擴展性;可伸縮性;可量測性;】.

【InnoDB is the default storage engine for new tables. In practice, the advanced InnoDB performance features mean that InnoDB tables often outperform the simpler MyISAM tables, especially for a busy database.】

• Does each table use an appropriate row format? This choice also depends on the storage engine used for the table. In particular, compressed tables use less disk space and so require less disk I/O to read and write the data. Compression is available for all kinds of workloads with InnoDB tables, and for readonly MyISAM tables.

• Does the application use an appropriate locking strategy? For example, by allowing shared access when possible so that database operations can run concurrently, and requesting exclusive access when appropriate so that critical operations get top priority. Again, the choice of storage engine is significant. The InnoDB storage engine handles most locking issues without involvement from you, allowing for better concurrency in the database and reducing the amount of experimentation and tuning for your code.

• Are all memory areas used for caching sized correctly? That is, large enough to hold frequently accessed data, but not so large that they overload physical memory and cause paging. The main memory areas to configure are the InnoDB buffer pool and the MyISAM key cache.

2.Optimizing at the Hardware Level

Any database application eventually hits hardware limits as the database becomes more and more busy. A DBA must evaluate whether it is possible to tune【tuːn (給收音機、電視等)調諧,調頻道;調整,調節(發動機);調整;(為樂器)調音,校音;】 the application or reconfigure the server to avoid these bottlenecks【ˈbɑtəlˌnɛks (尤指工商業發展的)瓶頸,阻礙,障礙;瓶頸路段(常引起交通阻塞);】, or whether more hardware resources are required. System bottlenecks typically arise from these sources:

• Disk seeks. It takes time for the disk to find a piece of data. With modern disks, the mean time for this is usually lower than 10ms, so we can in theory do about 100 seeks a second. This time improves slowly with new disks and is very hard to optimize for a single table. The way to optimize seek time is to distribute the data onto more than one disk.

• Disk reading and writing. When the disk is at the correct position, we need to read or write the data. With modern disks, one disk delivers at least 10–20MB/s throughput. This is easier to optimize than seeks because you can read in parallel from multiple disks.

• CPU cycles. When the data is in main memory, we must process it to get our result. Having large tables compared to the amount of memory is the most common limiting factor. But with small tables, speed is usually not the problem.

• Memory bandwidth. When the CPU needs more data than can fit in the CPU cache, main memory bandwidth【ˈbændwɪdθ 帶寬;頻寬;帶寬值,頻寬值(電腦網路或互聯網介面一定時間內傳送信息量的量度,按每秒傳送的位元組數計);】 becomes a bottleneck. This is an uncommon bottleneck for most systems, but one to be aware of.

3.Balancing Portability and Performance

To use performance-oriented SQL extensions in a portable【ˈpɔːrtəbl 攜帶型的;手提的;輕便的;】 MySQL program, you can wrap【ræp 包;裹(禮物等);(使文字)換行;用…包裹(或包扎、覆蓋等);用…纏繞(或圍緊);】 MySQL-specific keywords in a statement within /*! */ comment delimiters. Other SQL servers ignore the commented keywords.

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 時序圖 時序圖 1. 參考資料 2. 基礎 3. 符號 3.1. 斜線形式的上升沿、下降沿 3.2. Either or 信號 3.3. 波形省略 3.2.1. 虛線 3.2.2. 波浪號 3.4. 地址&數據表示 4. 實例-WT588F語音晶元時序圖 4.1. 瞭解背景 4.2. 分析 4.3. ...
  • 首先來看下什麼是漏桶演算法和令牌桶演算法 Nginx並不直接實現漏桶演算法或令牌桶演算法,但這些演算法在控制網路流量和請求速率方面非常有用。這些演算法通常在網路編程、API服務、負載均衡等領域中使用,以確保系統的穩定性和性能。 漏桶演算法(Leaky Bucket): * 漏桶演算法用於限制數據的傳輸速率。它可以將 ...
  • 文件IO 筆試題 作業:設計程式,獲取當前系統時間,把時間轉換為特定格式”yy年mm月dd日 星期x tt:mm:ss”,並每隔1s寫入到本地磁碟中一個叫做log.txt的文本中,如果文本不存在則創建。 代碼: /******************************************* ...
  • 目錄標準IO練習題題目:分析:代碼展示結果展示總結知識擴展time()函數localtime()函數 標準IO練習題 題目: 設計程式,獲取當前系統時間,把時間轉換為特定格式”yy年mm月dd日 星期x tt:mm:ss”,並每隔1s寫入到本地磁碟中一個叫做log.txt的文本中,如果文本不存在則創 ...
  • 目錄文件操作介面說明標準IO標準IO函數介紹打開文件:fopen()fopen使用相關知識補充關閉文件:fclose讀取數據字元讀取(fgetc)按行讀取按塊讀取寫入文件字元寫入字元串寫入按塊寫入讀取文件位置設置位移獲取位移格式訪問 文件操作介面說明 Linux系統為了簡化不同類型文件的操作流程,在 ...
  • 目錄電腦的組成部分硬體系統軟體系統文件系統Linux系統的目錄根文件系統說明目錄的結構分析Linux 的文件類型 電腦的組成部分 硬體系統 電腦的硬體主要是由五部分組成:控制器、運算器、存儲器、輸入設備、輸出設備。 運算器和控制器的總稱是中央處理器(CPU),指的是電腦中對信息進行高速運算處 ...
  • 目錄一、文本搜索工具--grep1、簡介2、工作原理3、語法格式4、選項介紹5、實例測試5.1、-i選項5.2、-v選項5.3、-n選項5.4、-c選項5.5、-o選項5.6、-B選項5.7、-A選項5.8、-C選項5.9、-w選項5.10、-E選項5.11、-e選項二、流編輯器--sed1、簡介2 ...
  • 目錄主要使用函數原型:實現過程中幾個易錯細節小結函數:每次讀寫一個字元函數:每次讀寫一行字元函數:每次讀寫一個塊字元 主要使用函數原型: 1.每次讀寫一個字元: int fgetc(FILE *stream); int fputc(int c, FILE *stream); 2.每次讀寫一行字元: ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...