最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

NewfeatureinMariaDB10.1:ANALYZEstatement_MySQL

来源:动视网 责编:小采 时间:2020-11-09 19:59:21
文档

NewfeatureinMariaDB10.1:ANALYZEstatement_MySQL

NewfeatureinMariaDB10.1:ANALYZEstatement_MySQL:MariaDB Last week, yours truly has pushed a new feature into MariaDB 10.1 tree: ANALYZE statement . The idea of this feature is to make it easy to compare query plan with query execution. ANALYZE statement will run the statement, and prod
推荐度:
导读NewfeatureinMariaDB10.1:ANALYZEstatement_MySQL:MariaDB Last week, yours truly has pushed a new feature into MariaDB 10.1 tree: ANALYZE statement . The idea of this feature is to make it easy to compare query plan with query execution. ANALYZE statement will run the statement, and prod
 MariaDB

Last week, yours truly has pushed a new feature into MariaDB 10.1 tree: ANALYZE statement .

The idea of this feature is to make it easy to compare query plan with query execution. ANALYZE statement will run the statement, and produce EXPLAIN-like output, where optimizer’s estimates are followed by numbers that were observed when running the query. The output looks like this:

Here,

  • Next to rows there is r_rows column which shows how many records were read from the table.
  • Next to filtered there is r_filtered column which shows which fraction of records was left after the part of the WHERE condition attached to the table was checked.
  • I think this should explain the feature. If you want more details, please refer to the KB article ANALYZE statement . It also discusses the meaning of the above EXPLAIN output.

    Technical details and further plans

    ANALYZE currently uses its own counters. Counting is done for all queries, including non-ANALYZE queries. This should be okay (not have visible overhead) as long as counting just increments integer variables in the query plan, without doing any atomic operations or making syscalls.

    The upside of this approach is that it’s now trivial to make Explain in the slow query log also print ANALYZE output. When a query runs slowly, you will be able to know where exactly the optimizer was wrong.

    The downside is that getting more data will not be as easy. So far, the most requested numbers beyond r_rows and r_filtered were r_time (amount of time spent in reading the table) and r_io (amount of IO that we did on the table). Counting the amount of time that was spent while reading each row will impose CPU overhead, it is a known problem. Counting IO is just incrementing a counter, but it will require interaction between ANALYZE code and storage engine(s) code, which will add complexity.

    There is PERFORMANCE_SCHEMA feature, where others have already spent a lot of effort to count wait time and IO. It’s tempting to reuse it. The problem is, P_S collects the wrong data. P_S counters are global, while ANALYZE needs to count IO for each table reference separately. Consider a self-join. From P_S point of view, it is reading from the same table. From ANALYZE point of view, it is reads from two different table references. I’m currently not sure whether ANALYZE should/could rely on PERFORMANCE_SCHEMA.

    A totally different angle is that tabular EXPLAIN output doesn’t allow to show much data (for example, how many rows were there before/after GROUP BY?). Here the solution is clear, I think: support EXPLAIN FORMAT=JSON and then add ANALYZE FORMAT=JSON where we can provide lots of detail.

    Posted inEXPLAIN,mysql,mariadbon June 30th, 2014 by spetrunia | |

    文档

    NewfeatureinMariaDB10.1:ANALYZEstatement_MySQL

    NewfeatureinMariaDB10.1:ANALYZEstatement_MySQL:MariaDB Last week, yours truly has pushed a new feature into MariaDB 10.1 tree: ANALYZE statement . The idea of this feature is to make it easy to compare query plan with query execution. ANALYZE statement will run the statement, and prod
    推荐度:
    标签: 10 mysql 10.1
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top