sridharplv
Valued Contributor II

HI @Sainath368 and @Waldar , Please find the below table which shows the difference between each queries which are causing the difference in counts and when to use which one.

sridharplv_0-1751999054634.png

 

 

Query Type Accuracy Based On Why It Differs

SELECT DISTINCTExactFull table scanReal values
approx_count_distinct()Approximate~98%Runtime estimationProbabilistic algorithm
DESCRIBE EXTENDEDApproximate or StaleCached metadataSampled/stale or not run at all

 

Purpose Use This

Data profiling / ReportingSELECT COUNT(DISTINCT col)
Fast estimateapprox_count_distinct(col)
Metadata for query planning

ANALYZE TABLE + DESCRIBE EXTENDED

 

View solution in original post