首页 > 其他分享 >ES profile 性能优化用——返回各个shard的耗时

ES profile 性能优化用——返回各个shard的耗时

时间:2023-08-03 22:06:49浏览次数:33  
标签:profile count shard score match time query ES

Profile API

都说要致富先修路,要调优当然需要先监控啦,elasticsearch在很多层面都提供了stats方便你来监控调优,但是还不够,其实很多情况下查询速度慢很大一部分原因是糟糕的查询引起的,玩过SQL的人都知道,数据库服务的执行计划(execution plan)非常有用,可以看到那些查询走没走索引和执行时间,用来调优,elasticsearch现在提供了Profile API来进行查询的优化,只需要在查询的时候开启profile:true就可以了,一个查询执行过程中的每个组件的性能消耗都能收集到。 

ES profile 性能优化用——返回各个shard的耗时_elasticsearch

那个子查询耗时多少,占比多少,一目了然,同时支持search和aggregation的profile!

Usage

Any _search request can be profiled by adding a top-level profile parameter:

GET /twitter/_search
{
  "profile": true,
"query" : {
    "match" : { "message" : "some number" }
  }
}

COPY AS CURLVIEW IN CONSOLE 

Setting the top-level profile parameter to true will enable profiling for the search

This will yield the following result:

{
   "took": 25,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "skipped" : 0,
      "failed": 0
   },
   "hits": {
      "total": 4,
      "max_score": 0.5093388,
      "hits": [...]
},
   "profile": {
     "shards": [
        {
           "id": "[2aE02wS1R8q_QFnYu6vDVQ][twitter][0]",
           "searches": [
              {
                 "query": [
                    {
                       "type": "BooleanQuery",
                       "description": "message:some message:number",
                       "time_in_nanos": "1873811",
                       "breakdown": {
                          "score": 51306,
                          "score_count": 4,
                          "build_scorer": 2935582,
                          "build_scorer_count": 1,
                          "match": 0,
                          "match_count": 0,
                          "create_weight": 919297,
                          "create_weight_count": 1,
                          "next_doc": 53876,
                          "next_doc_count": 5,
                          "advance": 0,
                          "advance_count": 0
                       },
                       "children": [
                          {
                             "type": "TermQuery",
                             "description": "message:some",
                             "time_in_nanos": "391943",
                             "breakdown": {
                                "score": 28776,
                                "score_count": 4,
                                "build_scorer": 784451,
                                "build_scorer_count": 1,
                                "match": 0,
                                "match_count": 0,
                                "create_weight": 1669564,
                                "create_weight_count": 1,
                                "next_doc": 10111,
                                "next_doc_count": 5,
                                "advance": 0,
                                "advance_count": 0
                             }
                          },
                          {
                             "type": "TermQuery",
                             "description": "message:number",
                             "time_in_nanos": "210682",
                             "breakdown": {
                                "score": 4552,
                                "score_count": 4,
                                "build_scorer": 42602,
                                "build_scorer_count": 1,
                                "match": 0,
                                "match_count": 0,
                                "create_weight": 89323,
                                "create_weight_count": 1,
                                "next_doc": 2852,
                                "next_doc_count": 5,
                                "advance": 0,
                                "advance_count": 0
                             }
                          }
                       ]
                    }
                 ],
                 "rewrite_time": 51443,
                 "collector": [
                    {
                       "name": "CancellableCollector",
                       "reason": "search_cancelled",
                       "time_in_nanos": "304311",
                       "children": [
                         {
                           "name": "SimpleTopScoreDocCollector",
                           "reason": "search_top_hits",
                           "time_in_nanos": "32273"
                         }
                       ]
                    }
                 ]
              }
           ],
           "aggregations": []
        }
     ]
   }
}


Search results are returned, but were omitted here for brevity

Even for a simple query, the response is relatively complicated. Let’s break it down piece-by-piece before moving to more complex examples.

First, the overall structure of the profile response is as follows:

{
   "profile": {
        "shards": [
           {
              "id": "[2aE02wS1R8q_QFnYu6vDVQ][twitter][0]","searches": [
                 {
                    "query": [...],"rewrite_time": 51443,"collector": [...]}
              ],
              "aggregations": [...]}
        ]
     }
}
A profile is returned for each shard that participated in the response, and is identified by a unique ID

Each profile contains a section which holds details about the query execution

Each profile has a single time representing the cumulative rewrite time

Each profile also contains a section about the Lucene Collectors which run the search

Each profile contains a section which holds the details about the aggregation execution


A profile is returned for each shard that participated in the response, and is identified by a unique ID


Each profile contains a section which holds details about the query execution


Each profile has a single time representing the cumulative rewrite time


Each profile also contains a section about the Lucene Collectors which run the search


Each profile contains a section which holds the details about the aggregation execution

标签:profile,count,shard,score,match,time,query,ES
From: https://blog.51cto.com/u_11908275/6953435

相关文章

  • SLF4J warning or error messages and their meanings(转)
     Themethod o.a.commons.logging.impl.SLF4FLogFactory#release wasinvoked.Giventhestructureofthecommons-loggingAPI,inparticularasimplementedbySLF4J,the o.a.commons.logging.impl.SLF4FLogFactory#release()methodshouldneverbecalled.However,d......
  • Codeforces Round 449 (Div. 1) D. Nephren Runs a Cinema 卡特兰数
    luogu链接题意不再赘述。优先枚举的应该是\(VIP\)用户,枚举范围应该是\([0,n-l]\)之后总客户数为\(s=n-i\)再考虑枚举\(100\)的总人数为\(x\)则要求\(s-2x\in[l,r]\)这部分方案数应该为从\((0,0)\)到达\((s-x,x)\)且不越过\(y=x\)的方案数。利用折线法求出方案数为\(C(s,x)......
  • delegate open and send for XMLHttpRequest by rewrite the prototype
     varsendProxied=window.XMLHttpRequest.prototype.send;window.XMLHttpRequest.prototype.send=function(){varobject={};letdata=arguments[0]if(data&&data.forEach){data.forEach((value,key)=>obj......
  • RestTemplate发送HTTP、HTTPS请求
     RestTemplate使用总结 场景:认证服务器需要有个httpclient把前端发来的请求转发到backendservice,然后把backendservice的结果再返回给前端,服务器本身只做认证功能。遇到的问题:长连接以保证高性能。RestTemplate本身也是一个wrapper其底层默认是 SimpleClientHtt......
  • S-H-ESD——就是先识别出趋势(中位数),然后做残差,利用残差看看正态分布的偏离点
    基于统计的异常检测方法S-H-ESD[twitter] 前10离群点中第三个点检测为异常,则至少有3个异常点S-ESD考虑ESD有如下两个限制:一是对于具有季节性的时间序列异常不能很好的识别,下图1中很多周期性变化的点并非异常点;二是多峰分布的数据点,一些低峰异常数据点不能被识别出来,如图2。图1时......
  • training acc比test acc小的情况
    今天跑实验遇到了trainingacc比testacc小的情况,查找了一些资料之后发现有以下一些可能:使用了dropout,在训练的时候使用了dropout,但是在test的时候其实没有dropout了。learningrate太大了,(我就属于这个情况)数据集太小了,导致方差很小。ref:https://stackoverflow.com/quest......
  • 读excel测试用例;登录;做pytest 请求
    1.从excel中读数据 返回【{字典}{字典}】;当传参数时,可以获得对应单元格内容importxlrdimportjsonfromconfigs.configsimportHOSTfromutils.md5importget_md5#在创建excel时,将登录接口的返回结果粘贴到excel时需要“只粘贴文本”#将excel实例化defget_exce......
  • update-alternatives 使用详解
    alternatives管理方式$ls-l/usr/bin/pythonlrwxrwxrwx1rootroot2411202017/usr/bin/python->/etc/alternatives/python$ls-l/etc/alternatives/pythonlrwxrwxrwx1rootroot1811212017/etc/alternatives/python->/usr/bin/python2.7python这个可执行命......
  • Oralce中processes和sessions的设置关系
    一,基本概念Sessions:指定了一个Instance中能够同时存在的sessions数量,或者说,就是能同时登陆到数据库的并发用户数。通常,我们设定这个参数时需要考虑我们可能会有多少个同时连接到数据库的并发用户,并加上后台进程的进程数,最后乘以1.1。processes:指定了Instance在OS层面所能同时运......
  • InnoDB – the best storage engine for MySQL?
    https://dev.mysql.com/doc/refman/5.7/en/innodb-introduction.html InnoDBisageneral-purposestorageenginethatbalanceshighreliabilityandhighperformance.InnoDB是一个通用的存储引擎,平衡了高可靠性和高性能。InMySQL5.7,InnoDBisthedefaultMySQLsto......