English 中文(简体)
MariaDB将10.3升至10.9,指数, eq_range_index_dive_limit andEXPLAIN
原标题:MariaDB upgrade 10.3 to 10.9, indexes, eq_range_index_dive_limit and EXPLAIN

正在升级的Im和MariadDB服务器从10.3(10.3.38-MariaDB-0ubuntu0.204.1)升至10.9(10.9.3-MariaDB-1:10.9.3+maria~ubu2004-log)

一段时间以来,我一直在当地操作10.9版本,准备在生产环境中安装。 由于我一直在努力优化一些较大的询问,我在当地注意到,某些情况下在生产过程中使用的指数是吨数。

我的理解是,它把这些版本的数字与试图成为“星号”的发动机之间的变化推向了使用优化成本的“星号”,而只是把表扫描仪指数的使用推向前进。 露骨的摩擦产生了以下几个方面:

eq_range_index_dive_limit, use_stat_tables, dis_buffer_size

我可能是个老点,但当我管理着EXPLAIN时,我看到一些可能的关键,但没有使用,这表明存在某种问题。 假设阿农研中心没有变化,就努力使指数开始使用。 我观察到,在升级后测试生产机器的同一行为与指数使用重复,我在当地看到的情况。

对我来说,一个员额是这样的假设,即电梯的实际结果并非完全“衡量”,而强迫指数是唯一的选择。 这是我所关切的——将10.9置于生产负荷之下(我难以可靠模拟)的生产环境,并看到经济放缓。

我为此做了些什么:

  1. Trust the changes between the version numbers, and cross my fingers that forgoing index usage will perform better, or
  2. Run all my queries through explain and start forcing indexes all over the place (which I did before I realized what was going on), because
  3. I m not even really sure how to gauge what s better, letting the engine decide not to use an index, or me forcing the index.

我与大家一样,对你中有些人如何处理这一问题,甚至对如何调整指数使用提出建议? 如果使用指数不像表扫描那样好,我是否真的会经历过放缓?

FWIW, I ve been up and down the setting values for those three server options above, and nothing changed the index usage for that simple SELECT statement...

感谢您的投入,下文将介绍这方面的情况。

MariaDB [pweb]> EXPLAIN extended select * from `accounting_transactions` where `accounting_transactions`.`cr_account` =  f7d78ef5-ca59-44d1-9d67-70a83960f473  G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: accounting_transactions
         type: ALL
possible_keys: accounting_transactions_cr_account_index
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 532030
     filtered: 35.63
        Extra: Using where
1 row in set, 1 warning (0.002 sec)
MariaDB [pweb]> EXPLAIN extended select * from `accounting_transactions` force index (accounting_transactions_cr_account_index ) where `accounting_transactions`.`cr_account` =  f7d78ef5-ca59-44d1-9d67-70a83960f473 G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: accounting_transactions
         type: ref
possible_keys: accounting_transactions_cr_account_index
          key: accounting_transactions_cr_account_index
      key_len: 144
          ref: const
         rows: 189558
     filtered: 100.00
        Extra: Using index condition
1 row in set, 1 warning (0.001 sec)
MariaDB [pweb]> SELECT VERSION();
+-------------------------------------------+
| VERSION()                                 |
+-------------------------------------------+
| 10.9.3-MariaDB-1:10.9.3+maria~ubu2004-log |
+-------------------------------------------+
1 row in set (0.001 sec)
MariaDB [pweb]> show create table accounting_transactions G
*************************** 1. row ***************************
       Table: accounting_transactions
Create Table: CREATE TABLE `accounting_transactions` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `dr_account` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `cr_account` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `accounting_transactions_event_id_index` (`event_id`),
  KEY `accounting_transactions_dr_account_index` (`dr_account`),
  KEY `accounting_transactions_cr_account_index` (`cr_account`),
  CONSTRAINT `accounting_transactions_cr_account_foreign` FOREIGN KEY (`cr_account`) REFERENCES `accounting_accounts` (`id`),
  CONSTRAINT `accounting_transactions_dr_account_foreign` FOREIGN KEY (`dr_account`) REFERENCES `accounting_accounts` (`id`),
  CONSTRAINT `accounting_transactions_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `accounting_events` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
1 row in set (0.002 sec)
MariaDB [pweb]> SHOW variables LIKE  %query_cache% ;
+------------------------------+----------+
| Variable_name                | Value    |
+------------------------------+----------+
| have_query_cache             | YES      |
| query_cache_limit            | 1048576  |
| query_cache_min_res_unit     | 4096     |
| query_cache_size             | 16777216 |
| query_cache_strip_comments   | OFF      |
| query_cache_type             | OFF      |
| query_cache_wlock_invalidate | OFF      |
+------------------------------+----------+
7 rows in set (0.002 sec)
MariaDB [pweb]> SHOW variables where Variable_name in ( eq_range_index_dive_limit ,  use_stat_tables ,  sort_buffer_size )G
*************************** 1. row ***************************
Variable_name: eq_range_index_dive_limit
        Value: 100000000
*************************** 2. row ***************************
Variable_name: sort_buffer_size
        Value: 209715200
*************************** 3. row ***************************
Variable_name: use_stat_tables
        Value: NEVER
3 rows in set (0.002 sec)

在某些情况下,根据实际的问答时间,我注意到,在没有指数使用的情况下更快地返回,我不得不说,这种情况非常令人惊讶。 这一支持选择1吗?

问题回答

91785/538368 -- 17% of the table is used.

当大部分的表格被搁置时,可以更快地填写表格。 当使用指数时,该指数需要在指数与数据变异之间重新出现。 http://em>。 超过通过数据进行线扫描的时间,使83%的浏览量达到。

Alas,the Bestizer没有适当的统计数据来说明哪一种方法更快。

本案的结果规模可能太大,无法适应凯恩斯。 因此,即使它被推翻,试图使用QC可能只是导致额外的间接费用。

您可以做的一件事是缩小CHAR(36)strings。 要么使用统一数据类型,要么至少将其包装到<条码>。 My UUIDs blog about such 哪怕是在数据类型存在之前。

客人与91785人行将做什么? 另一端: 如果客户不使用所有栏目,只列出必要的栏目,而不必使用“条形表>。





相关问题
Can someone explain this SQL query to me?

I m reading this article and I m trying to understand this SQL statement but I am still somewhat new to SQL. I m not sure what comment and c refer to. I think one of them is the table name but I am ...

In mysql, is "explain ..." always safe?

If I allow a group of users to submit "explain $whatever" to mysql (via Perl s DBI using DBD::mysql), is there anything that a user could put into $whatever that would make any database changes, leak ...

JDBC Oracle - Fetch explain plan for query

Im wondering how I can fetch the explain plan using Java. Reason I need this is because we have a framework where special users can craft reports. These reports sometimes build huge queries in which ...

mysql three joins

I have a problem with mysql I have 3 tables: Deposit +-------------------+-------------+------+-----+ | Field | Type | Null | Key | +-------------------+-------------+------+-----+...

PostgreSQL: exists vs left join

I heard many times that postgres handles exists queries even faster then left join. http://archives.postgresql.org/pgsql-performance/2002-12/msg00185.php That s definitely true for one table ...

How to optimize this mysql query - explain output included

This is the query (a search query basically, based on tags):- select SUM(DISTINCT(ttagrels.id_tag in (2105,2120,2151,2026,2046) )) as key_1_total_matches, td.*, u.* from Tutors_Tag_Relations AS ...

sqlite explain from api

I have a complicated SQL query executed from my application. The query runs fine with the version 3.6.11 (64ms). When run in 3.6.22 it takes more than 100 sec to finish. When executed from the command ...

Mysql Query optimisation

Query 1: SELECT cid, dl FROM chal WHERE cid IN ( SELECT cid FROM c_users WHERE uid = 636587 ); Query 2: SELECT chal.cid AS cid, chal.dl ...

热门标签