Adsense Ad

Friday, 13 September 2019

Oracle 12c New Features " APPROX_COUNT_DISTINCT "


Have you ever been investigating a table and wanted to find out how many records it contains with a simple SELECT COUNT(*) query, but the query took a long time to run? Or, if you wanted to find the number of distinct values in a column, but the query was slow?

Well, we now have an easier way to run this query.

A new function, called APPROX_COUNT_DISTINCT. This lets you find the approximate number of distinct values in a column.

It's called an approximate because it doesn't give you the exact number. But, the number is pretty close.
Hide Copy Code

SELECT COUNT(DISTINCT first_name) FROM student; 

SELECT APPROX_COUNT_DISTINCT(first_name) FROM student;

The first query uses the actual COUNT function, and the second uses the new function. The second query should run a lot faster and get a number that is pretty close to the correct one.

No comments: