Postgres Count Distinct Substrings