15

Our ex-employee wrote an amazing SQL SELECT-query consisting of 6449 characters. It has 11 JOINS and takes a solid minute to execute.

The table it fetches from has 16 records and the SQL query returns 46857 records and it was production code lmao

Comments
  • 10
    Wtf? 16 records? That doesn‘t even justify a DB!
  • 5
    Databases are surprisingly fast

    And then people do god forsaken things like this and then they aren't
  • 5
    @Lensflare They've been waiting for the 17th record to insert since 2018.
  • 3
    @Lensflare it doesn't even justify saying the word DB in the convo.

    Cache that shit and work with it.
  • 2
    @Lensflare 16 records in that table of a new feature that is in prod but a few customers have access to it.
  • 1
    is he trying to code using SQL

    has he tried just using the CPU

    cloud computing oficiados I swear
  • 3
    What- What does it even do?!
  • 3
    Joins against one table with 16 records eh? Impressive!
  • 1
    The only stat that doesn’t completely knock me on my ass is the 11 joins. The rest are absolutely unbelievable.
  • 1
    @jestdotty I have a longstanding argument in favour of key-value DBs; they force all decisions onto the compute node so storage is reducible to a pile of network and storage hardware and the smallest OS that can run the DB. Sure an individual task is drastically slower, but they can be parallelized much better. Also I think dealing with databases as data you put in an index rather than indexes you create over data builds character. It's not entirely serious either way but I think it would be interesting to see the kind of practices that evolve when you execute _zero custom logic_ on the storage nodes.
  • 0
    Are you storing in JSON or something and the poor DB has to parse it?
  • 2
    @AlgoRythm Around 5k characters is just stuff like "status"."id" AS "status_id". The word " AS " is found 100 times in the query.

    I'm not a back-end developer but that looks like shit.
  • 3
    @Ranchonyx It retrieves data about conversations, related tickets, priorities, categories, ...

    Front-end colleague fixed the query and executation time dropped to 0.085 seconds. It now runs around 835x faster and the output is correct.
  • 2
    @wojtek322 aliases are dead common in ETL, less common but still commonplace in regular application use. It’s a code smell, well-built applications might have none at all.
  • 1
    Why does this sound familiar?
Add Comment