You can use this:
SELECT COUNT(*) FROM (SELECT DISTINCT column_name FROM table_name) AS temp;
This is much faster than:
COUNT(DISTINCT column_name)
More Related Contents:
- LOWER LIKE vs iLIKE
- MongoDB ‘count()’ is very slow. How do we refine/work around with it?
- How to efficiently count the number of keys/properties of an object in JavaScript
- Speed up the loop operation in R
- One could use a profiler, but why not just halt the program? [closed]
- Spark functions vs UDF performance?
- Adding a redundant assignment speeds up code when compiled without optimization
- Why is this SSE code 6 times slower without VZEROUPPER on Skylake?
- How many Include I can use on ObjectSet in EntityFramework to retain performance?
- Faster way to find the first empty row in a Google Sheet column
- 32-byte aligned routine does not fit the uops cache
- Why is SSE scalar sqrt(x) slower than rsqrt(x) * x?
- Haskell foldl’ poor performance with (++)
- Which Intel microarchitecture introduced the ADC reg,0 single-uop special case?
- Storing Documents as Blobs in a Database – Any disadvantages?
- Can modern x86 implementations store-forward from more than one prior store?
- Cellfun versus Simple Matlab Loop performance
- timing code in matlab
- Minimizing overhead due to the large number of Numpy dot calls
- What are the rules for the “Ω(n log n) barrier” for sorting algorithms?
- Getting total row count from OFFSET / FETCH NEXT
- Content-Length header versus chunked encoding
- How to find pair with kth largest sum?
- Git is really slow for 100,000 objects. Any fixes?
- Does Scala support tail recursion optimization?
- Memory Allocation/Deallocation Bottleneck?
- Move all odd positioned element to left half and even positioned to right half in-place
- preallocate list in R
- How to analyze golang memory?
- How to avoid Query Plan re-compilation when using IEnumerable.Contains in Entity Framework LINQ queries?