SQL最佳化 —— 讀懂執行計劃
Bucket and Batch
I saw that functions which use hash join, like as ExecHashGetBucketAndBatch and ExecScanHashBucket, have bucket and batch concepts. So, I would like to know the differences between bucket and batch. I dont understand tables partitioning mechanism in hash join.
A bucket is, well, one bucket of a hash table --- it holds all the tuples that have the same hash code (for as many bits of the hash code as we are choosing to use). We try to size the hash table with enough buckets so there's not more than 10 tuples per bucket on average. A batch is a range of buckets that we process at the same time. Tuples (from either side of the join) whose hash codes show they fall into batches other than the first one get dumped into temporary holding files, and then (after finishing joining the first batch) we pull each successive batch back into memory and join that portion of the tuples. The batch size is chosen to make the amount of memory needed be approximately work_mem. IOW, there are really nbuckets * nbatches "virtual" buckets in the hash table, but only nbuckets worth of them are kept in memory at any one time.
Note that we don't currently do batches for hash aggregates, only joins currently.
show Heap Fetches in EXPLAIN for index-only scans
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26477398/viewspace-2128499/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 讀懂MySQL執行計劃MySql
- 讀懂 MySQL 執行計劃MySql
- 這一次,徹底讀懂Mysql執行計劃MySql
- sql 執行計劃SQL
- 分析執行計劃最佳化SQLORACLE的執行計劃(轉)SQLOracle
- SQL最佳化案例-從執行計劃定位SQL問題(三)SQL
- spark sql語句效能最佳化及執行計劃SparkSQL
- Oracle sql執行計劃OracleSQL
- SQL Server執行計劃SQLServer
- SQL的執行計劃SQL
- SQL執行計劃分析SQL
- 閱讀執行計劃
- Calcite執行計劃最佳化
- sql最佳化:使用儲存提綱穩定sql執行計劃SQL
- 【sql調優之執行計劃】獲取執行計劃SQL
- 微課sql最佳化(9)、如何獲取執行計劃SQL
- 微課sql最佳化(11) 、如何檢視執行計劃SQL
- 透過分析SQL語句的執行計劃最佳化SQL(總結)SQL
- 獲取SQL執行計劃SQL
- SQL 執行計劃案例1SQL
- 剖析SQL Server執行計劃SQLServer
- 檢視sql執行計劃SQL
- Oracle閱讀執行計劃Oracle
- [轉]透過分析SQL語句的執行計劃最佳化SQL(總結)SQL
- Mysql SQL最佳化系列之——執行計劃連線方式淺釋MySql
- sql執行計劃是否改變SQL
- sql的執行計劃 詳解SQL
- sql執行計劃基本命令SQL
- SQL PROFILE修改固定執行計劃SQL
- 使用sql profile固定執行計劃SQL
- 執行計劃的閱讀方法
- Oracle中檢視已執行sql的執行計劃OracleSQL
- 【最佳化】SPM(上)自動捕獲sql執行計劃並演進SQL
- 【最佳化】explain plan for 方式存取執行計劃AI
- 如何檢視SQL的執行計劃SQL
- 檢視SQL的執行計劃方法SQL
- Oracle 獲取SQL執行計劃方法OracleSQL
- baseline固定SQL執行計劃SQL