(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46132],{37666:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/cloud/sql-manual/functions/aggregate-functions/percentile_approx.en-US",function(){return n(71119)}])},71119:function(e,s,n){"use strict";n.r(s),n.d(s,{__toc:function(){return i}});var t=n(52322),a=n(28287),l=n(71199);let i=[{depth:2,value:"PERCENTILE_APPROX",id:"percentile_approx"},{depth:3,value:"Description",id:"description"},{depth:3,value:"Example",id:"example"},{depth:3,value:"Keywords",id:"keywords"}];function r(e){let s=Object.assign({h2:"h2",h3:"h3",p:"p",strong:"strong",code:"code",pre:"pre",span:"span"},(0,l.a)(),e.components);return(0,t.jsxs)(t.Fragment,{children:["\n",(0,t.jsx)(s.h2,{id:"percentile_approx",children:"PERCENTILE_APPROX"}),"\n",(0,t.jsx)(s.h3,{id:"description",children:"Description"}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.strong,{children:"Syntax:"})}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.code,{children:"PERCENTILE_APPROX(expr, DOUBLE p[, DOUBLE compression])"})}),"\n",(0,t.jsx)(s.p,{children:"This function returns the approximation of th p percentile. The value of P is between 0 and 1."}),"\n",(0,t.jsx)(s.p,{children:"The compression parameter is optional. Its range is [2048, 10000]. Larger compression values brings more precise results, but also, more time and memory costs. If the compression parameter is not specified or set beyond [2048, 10000], the system will consider it to be 10000."}),"\n",(0,t.jsx)(s.p,{children:"This function uses fixed-size memory, so it can reduce memory usage of high-cardinality columns. It can be used to calculate statistics such as tp99."}),"\n",(0,t.jsx)(s.h3,{id:"example",children:"Example"}),"\n",(0,t.jsx)(s.pre,{"data-language":"text","data-theme":"default",hasCopyCode:!0,children:(0,t.jsxs)(s.code,{"data-language":"text","data-theme":"default",children:[(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"MySQL > select `table`, percentile_approx(cost_time,0.99) from log_statis group by `table`;"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"+---------------------+---------------------------+"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"| table    | percentile_approx(`cost_time`, 0.99) |"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"+----------+--------------------------------------+"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"| test     |                                54.22 |"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"+----------+--------------------------------------+"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"}})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"MySQL > select `table`, percentile_approx(cost_time,0.99, 4096) from log_statis group by `table`;"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"+---------------------+---------------------------+"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"| table    | percentile_approx(`cost_time`, 0.99, 4096.0) |"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"+----------+--------------------------------------+"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"| test     |                                54.21 |"})}),"\n",(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"+----------+--------------------------------------+"})})]})}),"\n",(0,t.jsx)(s.h3,{id:"keywords",children:"Keywords"}),"\n",(0,t.jsx)(s.pre,{"data-language":"text","data-theme":"default",hasCopyCode:!0,children:(0,t.jsx)(s.code,{"data-language":"text","data-theme":"default",children:(0,t.jsx)(s.span,{className:"line",children:(0,t.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"PERCENTILE_APPROX,PERCENTILE,APPROX"})})})})]})}s.default=(0,a.j)({MDXContent:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:s}=Object.assign({},(0,l.a)(),e.components);return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(r,{...e})}):r(e)},pageOpts:{filePath:"pages/cloud/sql-manual/functions/aggregate-functions/percentile_approx.en-US.md",route:"/cloud/sql-manual/functions/aggregate-functions/percentile_approx",frontMatter:{title:"PERCENTILE_APPROX",language:"en"},timestamp:1728445633e3,title:"PERCENTILE_APPROX",headings:i},pageNextRoute:"/cloud/sql-manual/functions/aggregate-functions/percentile_approx.en-US"})}},function(e){e.O(0,[28287,92888,49774,40179],function(){return e(e.s=37666)}),_N_E=e.O()}]);