{"id":1755,"date":"2016-09-21T01:47:05","date_gmt":"2016-09-21T06:47:05","guid":{"rendered":"https:\/\/bijoos.com\/oraclenotes\/?p=1755"},"modified":"2026-02-07T15:34:42","modified_gmt":"2026-02-07T21:34:42","slug":"approximate-query-processing-in-12c-release-2","status":"publish","type":"post","link":"https:\/\/bijoos.com\/oraclenotes\/2016\/1755\/","title":{"rendered":"Approximate Query Processing in 12c Release 2"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/bijoos.com\/oraclenotes\/wp-content\/uploads\/2016\/09\/dbcloud.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\" wp-image-1756 alignleft\" src=\"https:\/\/i0.wp.com\/bijoos.com\/oraclenotes\/wp-content\/uploads\/2016\/09\/dbcloud.png?resize=79%2C79&#038;ssl=1\" alt=\"dbcloud\" width=\"79\" height=\"79\" \/><\/a>Approximate Query Processing appears to be a major feature of Oracle Database 12c Release 2 SQL. In 12cR1 patchset 2 (12.1.0.2), we saw one approximate query function appear &#8211; APPROX_COUNT_DISTINCT to use instead of COUNT(DISTINCT). In 12.2 there are several APPROX functions introduced:<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><code>APPROX_COUNT_DISTINCT_DETAIL<\/code><\/li>\n<li><code>APPROX_COUNT_DISTINCT_AGG<\/code><\/li>\n<li><code>TO_APPROX_COUNT_DISTINCT<\/code><\/li>\n<li><code>APPROX_MEDIAN<\/code><\/li>\n<li><code>APPROX_PERCENTILE<\/code><\/li>\n<li><code>APPROX_PERCENTILE_DETAIL<\/code><\/li>\n<li><code>APPROX_PERCENTILE_AGG<\/code><\/li>\n<li><code>TO_APPROX_PERCENTILE<\/code><\/li>\n<\/ul>\n<p>According to Oracle documentation, &#8220;Approximate query processing is primarily used in data discovery applications to return quick answers to explorative queries. Users typically want to locate interesting data points within large amounts of data and then drill down to uncover further levels of detail. For explorative queries, quick responses are more important than exact values.&#8221;<\/p>\n<p>The interesting part is that you can utilize\u00a0the Approximate functions without changing code. There are three\u00a0initialization parameters introduced to control which functions should be treated as an approximate function during run time&#8230; cool!<\/p>\n<p>The initialization parameters are:<\/p>\n<ul>\n<li><code>approx_for_aggregation<\/code><\/li>\n<li><code>approx_for_count_distinct<\/code><\/li>\n<li><code>approx_for_percentile<\/code><\/li>\n<\/ul>\n<p>To replace only the <code>COUNT(DISTINCT)<\/code> function in queries with the <code>APPROX_COUNT_DISTINCT<\/code> function, set the <code>approx_for_count_distinct<\/code> initialization parameter to <code>TRUE<\/code> for the current session or for the entire database.<\/p>\n<p>To replace percentile functions with the corresponding functions that return approximate results, set <code>approx_for_percentile<\/code> to <code>PERCENTILE_CONT<\/code>, <code>PERCENTILE_DISC<\/code>, or <code>ALL<\/code> (replaces all percentile functions) for the current session or for the entire database.<\/p>\n<p>To run all queries using the corresponding SQL functions that return approximate results instead of the specified SQL functions, set the <code>approx_for_aggregation<\/code> initialization parameter to <code>TRUE<\/code> for the current session or for the entire database.<\/p>\n<p>Read more&#8230; <a href=\"https:\/\/docs.oracle.com\/cloud\/latest\/exadataexpress-cloud\/CSDBF\/approximate-query-processing.htm#CSDBF-GUID-6A387B85-B347-4065-8A48-8F3E4AA91F87\" target=\"_blank\">Oracle Documentation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Approximate Query Processing appears to be a major feature of Oracle Database 12c Release 2 SQL. In 12cR1 patchset 2 (12.1.0.2), we saw one approximate query function appear &#8211; APPROX_COUNT_DISTINCT to use instead of COUNT(DISTINCT). In 12.2 there are several APPROX functions introduced: &nbsp; APPROX_COUNT_DISTINCT_DETAIL APPROX_COUNT_DISTINCT_AGG TO_APPROX_COUNT_DISTINCT APPROX_MEDIAN APPROX_PERCENTILE APPROX_PERCENTILE_DETAIL APPROX_PERCENTILE_AGG TO_APPROX_PERCENTILE According to Oracle &#8230; <a title=\"Approximate Query Processing in 12c Release 2\" class=\"read-more\" href=\"https:\/\/bijoos.com\/oraclenotes\/2016\/1755\/\" aria-label=\"Read more about Approximate Query Processing in 12c Release 2\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[133],"tags":[],"class_list":["post-1755","post","type-post","status-publish","format-standard","hentry","category-oracledb"],"acf":[],"jetpack-related-posts":[{"id":2121,"url":"https:\/\/bijoos.com\/oraclenotes\/2017\/2121\/","url_meta":{"origin":1755,"position":0},"title":"Adaptive Query Performance Fixes for #DB12c Release 1","author":"Biju","date":"December 5, 2017","format":false,"excerpt":"We all know adaptive query feature introduced in Oracle Database Release 1 is a problem. Recently I had the opportunity to review few 12cR1 databases and found that to alleviate the performance problems, the DBA set parameter OPTIMIZER_FEATURES_ENABLE=11.2.0.4 in Oracle Database 12c Release 1 (12.1.0.2). This observation is the catalyst\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1720,"url":"https:\/\/bijoos.com\/oraclenotes\/2016\/1720\/","url_meta":{"origin":1755,"position":1},"title":"Oracle Tidbits &#8211; May 2016","author":"Biju","date":"June 1, 2016","format":false,"excerpt":"\u201cOracle *daily* TidBits\u201d (#oratidbit) published at\u00a0https:\/\/www.facebook.com\/oraclenotes\u00a0on weekdays\u00a0in May\u00a02016. You will also see these tidbits, one tidbit at a time, for each page refresh on the right side of this blog as well\u2026 Hope you find these helpful to learn something new or to remind you of its existence and use\u2026\u2026","rel":"","context":"In &quot;TidBits &amp; Quick Tips&quot;","block_context":{"text":"TidBits &amp; Quick Tips","link":"https:\/\/bijoos.com\/oraclenotes\/category\/tidbits\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":153,"url":"https:\/\/bijoos.com\/oraclenotes\/2013\/153\/","url_meta":{"origin":1755,"position":2},"title":"OracleDB12c New Feature: Last Login Time of User","author":"Biju","date":"July 9, 2013","format":false,"excerpt":"The SYS.USER$ table in Oracle Database 12c includes a column to store the last login time of the user. In the previous releases, to be able to know the last login time of the user, we had to enable \"AUDIT SESSION\" and then query the AUD$ table. As part of\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1473,"url":"https:\/\/bijoos.com\/oraclenotes\/2014\/1473\/","url_meta":{"origin":1755,"position":3},"title":"Oracle 12c &#8211; READ Privilege","author":"Biju","date":"December 23, 2014","format":false,"excerpt":"The READ privilege is new in Oracle Database 12c 12.1.0.2. Why do we need a READ privilege when there is SELECT privilege? Well, the SELECT privilege includes few more privilege than a pure read-only privilege! With the SELECT privilege, in addition to reading (or \u201cselecting\u201d from) the table, you are\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":495,"url":"https:\/\/bijoos.com\/oraclenotes\/2014\/495\/","url_meta":{"origin":1755,"position":4},"title":"Oracle TidBits &#8211; July 2014","author":"Biju","date":"August 1, 2014","format":false,"excerpt":"\u201cOracle *daily* TidBits\u201d published at\u00a0https:\/\/www.facebook.com\/oraclenotes\u00a0on all weekdays\u00a0in July 2014. You will also see these tidbits, one tidbit at a time, for each page refresh on the right side of this blog as well\u2026 Hope you find these helpful to learn something new or to remind you of its existence and\u2026","rel":"","context":"In &quot;TidBits &amp; Quick Tips&quot;","block_context":{"text":"TidBits &amp; Quick Tips","link":"https:\/\/bijoos.com\/oraclenotes\/category\/tidbits\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1572,"url":"https:\/\/bijoos.com\/oraclenotes\/2015\/1572\/","url_meta":{"origin":1755,"position":5},"title":"OCA12c \u2013 1Z0-061 \u2013 Additional Reading 02","author":"Biju","date":"September 4, 2015","format":false,"excerpt":"[Additional] Reading material for 1z0-061 Oracle Database 12c SQL Fundamentals test. Chapter 2: Introducing SQL\u00a0introduces you to writing simple queries using SELECT statement. It also introduces you to filtering and sorting data. 2 Retrieving Data Using the SQL SELECT Statement 2.1 Explain the capabilities of SQL SELECT statements 2.2 Execute\u2026","rel":"","context":"In &quot;Certification &amp; Learning&quot;","block_context":{"text":"Certification &amp; Learning","link":"https:\/\/bijoos.com\/oraclenotes\/category\/certification-learning\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/1755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/comments?post=1755"}],"version-history":[{"count":1,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/1755\/revisions"}],"predecessor-version":[{"id":3011,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/1755\/revisions\/3011"}],"wp:attachment":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/media?parent=1755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/categories?post=1755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/tags?post=1755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}