Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Revealing the details of how OpenAI agents hacked Hugging Face (swarmtraces.org)
    241comments
  2. A single function Jev-like wrapper for LLMs, including vision models (allanrbo.blogspot.com)
    2comments
  3. Plan mode is dead (aymannadeem.com)
    222comments
  4. Ollaya – Ollama for open-source, Jev-style decision models (ollaya.dev)
    112comments
  5. Show HN: Jev Plays Pokémon Red (jev-pokemon.vercel.app)
    79comments
  6. What even is an OS now? (sockpuppet.org)
    252comments
  7. Postgres SELECT DISTINCT Does Not Scale (dbos.dev)
    17comments
  8. The Murky History of Soviet-Born Tetris (mitpress.mit.edu)
    5comments
  9. Jury finds Facebook liable for deceiving users in Cambridge Analytica case (cbsnews.com)
    34comments
  10. How I changed teaching after AI managed to do all my homework assignments (thelastsoftwareengineer.substack.com)
    4comments
  11. Gravity seems holographic. What does that mean for reality? (quantamagazine.org)
    158comments
  12. Show HN: Hacker Atlas - A map of what Hacker News talks about (hackeratlas.com)
    12comments
  13. One Piece of Flock Camera Data Put This Innocent Woman in Jail for 13 Days (jezebel.com)
    55comments
  14. A new world airport and its baggage (computer.rip)
    —discuss
  15. Fourier Analysis: Drawing Llamas with Circles (adekau.github.io)
    1comments
  16. Lab on a Contact Lens Can Measure Stress Through Serotonin (ieee.org)
    6comments
  17. Excel now supports multiple values in a single cell (techcommunity.microsoft.com)
    110comments
  18. Two and a half years without a gallbladder (tracydurnell.com)
    17comments
  19. We're gonna need a lot more mathematicians (terrytao.wordpress.com)
    83comments
  20. HomelabFest will be in St. Louis in September 2027 (homelabfest.org)
    8comments
  21. First Principles Thinking (sunilsadasivan.com)
    107comments
  22. I wrote a ray tracer in Brainfuck (epestr.com)
    15comments
  23. U.S. appeals court upholds designation of Anthropic as supply chain risk (cnbc.com)
    746comments
  24. Remembering Johannes Doerfert (llvm.org)
    2comments
  25. Microsoft abandons personal AI chatbot race with Copilot reboot (bloomberg.com)
    103comments
  26. How video games inspire great UX (2019) (jenson.org)
    17comments
  27. What happens when you analyze your favorite college football team like the CIA? (cultivatelabs.com)
    30comments
  28. How we learned to stop worrying and love campus surveillance (fnl.mit.edu)
    106comments
  29. Show HN: Make math automatic with Mathy (gmays.com)
    25comments
  30. Platform-independent SIMD in Go (go.dev)
    137comments

Postgres SELECT DISTINCT Does Not Scale

57 pointsby 1d agodbos.dev
16 comments
4h agoHN ↗

"Postgres SELECT DISTINCT Does Not Scale"

Correct. This is documented in depth: DISTINCT sorts the results first.

The article's use case seems to imply the author did not know about GROUP BY, nor does it imply the author knew about indexes, nor ANALYZE. Postgres 18's new skip scan indexing also could help here, so ensuring the planner chooses that could help.

4h agoHN ↗

Would GROUP BY fix the issue?

The article explains that skip scan doesn't do anything here.

nor does it imply the author knew about indexes, nor ANALYZE

Indexes were talked about a lot, and they explicitly mentioned looking at the query plan.

1h agoHN ↗

nope - either gets you a HashAggregate, GroupAggregate, or Unique depending on whether the column/input is indexed/ordered

1h agoHN ↗

The article seems to have changed since I commented.

46m agoHN ↗

Why don't he use GROUP BY on indexed columns was my first thought also.

I guess we just have to patiently wait for the OP to hopefully read Postgres documentation from postgreSQL 10.x before correcting the article again.

35m agoHN ↗

Does that fix it? Why would people be trying to add new index scanning modes if that's enough to fix it?

Someone else said it doesn't.

2h agoHN ↗

Did you even read the article? They show that a perfect index for their query didnt help because Skip Scan is currently not used for DISTINCT queries.

1h agoHN ↗

The article seems to have changed since I commented.

49m agoHN ↗

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.

30m agoHN ↗

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.

20m agoHN ↗

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

27m agoHN ↗

It's Stonebraker, he has a history of doing this to sell shit to people who don't need it.