‹ BackHN Continuity

Thread

Postgres SELECT DISTINCT Does Not Scale

106 points · 28 comments · KraftyOne

  1. sandeepkd · · focus · HN ↗
    It says that the company is co-founded by Postgres creator. I find that bit hard to believe given that there is nothing novel in the article, probably discovery for them. I do understand that everyone has to go through their own journey to learn these things but at the same time when you are running business then seeking professional help isnt a bad idea.

    Based on my experience queries like these cannot scale, whatever you do. However if you are already on a path where you had invested a lot in such queries then hire a DBA, if you are not far off then hire an architect to model the data for better performance.

    1. Dylan16807 · · focus · HN ↗
      Scale with what? If you have m distinct values in an index, then listing them this way takes m log(n) time, which is fine for many use cases no matter how much data you have.
      1. sandeepkd · · focus · HN ↗
        The way the OP is trying to achieve all the goals by pushing the complexity on the queries/database is what I am referring to as non-scalable as data grows on SQL DB.

        > If you have m distinct values in an index, then listing them this way takes m log(n) time, which is fine for many use cases no matter how much data you have.

        And NO the runtimes are not right away applicable on machines at scale. You are dealing with DB locks, page sizes, available memory, existing data in memory, queue depth. Experienced folks get paid to short circuit such learnings

        1. Dylan16807 · · focus · HN ↗
          Selecting distinct values of a single column with a simple condition is hardly pushing complexity into the database.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.