The DISTINCT in Your COUNT(boringsql.com) |
The DISTINCT in Your COUNT(boringsql.com) |
https://en.wikipedia.org/wiki/Flajolet%E2%80%93Martin_algori...
which fits on 10 lines and does not require sorting. Improved versions of it are LogLog and HyperLogLog.