r/ProgrammerHumor • • Oct 28 '26

Meme whatPeopleSeeWhenTheyLookAtMyCursedCode

Post image
275 Upvotes

41 comments sorted by

44

u/7DBBA101 Oct 28 '26

real query btw

18

u/ClankerDeveloper Oct 28 '26

Is that a dynamic sql string that you're executing?

Either way, please stop torturing the db.

29

u/7DBBA101 Oct 28 '26

This is exactly what relational databases are made for. Its just a static query to get the 10 newest products added to a webshop and display their thumbnail, brand and name on the front page.

2

u/ClankerDeveloper Oct 28 '26

What rdbms are you using? I use sql server to pay the bills, and the red text and quotes make it look like a dynamic sql trainwreck to me.

55

u/mrcoffee09 Oct 28 '26

What?? This is beautiful. CTEs with windowed analytic functions and... comments?? This is good shit right here boys

8

u/7DBBA101 Oct 28 '26

The entire project is so fast, it feels snappy on dialup

17

u/TheWb117 Oct 28 '26

Fr, this is a few lines, but it's perfectly readable and easy to reason about what it's doing. I've come across (and even written) far worse

7

u/aa-b Oct 28 '26

Yep, my rule is I never complain about necessary complexity. Complicated code is bad, but a single complex query is usually better than the alternative. I'd rather have this than some huge script that needs actual maintenance.

30

u/WisePotato42 Oct 28 '26

Is that 0.3% other the readme.md file?

3

u/Literally-in-1984 Oct 30 '26

A markdown file explaining why I love SQL and that it is a Turing complete language

2

u/7DBBA101 Oct 30 '26

PHP is just a fancy way to call SQL programs

46

u/Significant_Log9494 Oct 28 '26

The other 0.3% is an apology.

5

u/none-exist Oct 28 '26

We apologize for the inconvenience

-3

u/read_eet Oct 28 '26

The 0.3% which is AI

9

u/MayoJam Oct 28 '26

They see... SQL?

13

u/TWIT_TWAT Oct 28 '26

A 1,000 line stored procedure containing all of the client’s business logic.

13

u/7DBBA101 Oct 28 '26

I’m pretty confident I could squeeze the entire eod batch processing of a small bank into one unmaintainable multi-thousand line SQL query

4

u/Old_Tourist_3774 Oct 28 '26

The sign of a master

3

u/MayoJam Oct 28 '26

Aaah so it's python magic one liner case. 100% compact, 0% maintainability.

3

u/sndrtj Oct 28 '26

Whats wrong with some CTEs?

1

u/7DBBA101 Oct 28 '26

the CTE is missing some recursion

3

u/G3nghisKang Oct 28 '26

Tsk tsk, my big, girthy Oracle PL/SQL batches would put your small puny query to shame

2

u/7DBBA101 Oct 28 '26

at least my database server doesnt have massive memory leaks and crashes when more than 12 clients are in the connection pool

2

u/G3nghisKang Oct 28 '26 edited Oct 28 '26

When you work in application maintenance, the memory leaks are just extra job security UwU

20

u/Anonymislim Oct 28 '26

The only other file in the repo is an APOLOGY.md

2

u/ZiCli Oct 29 '26

You got me, nice.

5

u/redditmarks_markII Oct 28 '26

data centric companies do a lot with sql, probably more than they should, but it's rather amusing most of it works. or rather, stored procs. so, so many stored procs. that call stored procs. that the client application uses to eventually instantiate new containers...that call stored procs. that emits metrics, and that the client application uses to generate alerts... using stored procs. it's a symphony of madness. most of it is actually pretty good, if I believe the ones who wrote them.

4

u/SmurfMann91 Oct 28 '26

Soo.... I write large dynamic SQL queries as well as huge CTE stacks to provide increasingly granular layers of data for downstream processing....

....this is top tier.

I know nothing exists in a vacuum -- but I dig this so far.

1

u/21Ali-ANinja69 Oct 28 '26

Rather this than have people try their very best to string-build a query in C or something even dumber

2

u/7DBBA101 Oct 28 '26

He who never listed all the 20000 touples he wanted verbatim in the SQL query throws the first stone

1

u/00Koch00 Oct 29 '26

Those comments are so suspicious...

But aside that, beautiful code, that's being said, what's the reason to use a dynamic query for this? Is this T-SQL?

1

u/7DBBA101 Oct 29 '26

Mariadb. The reason is that it doesnt matter because the entire request (the whole program including the query) finishes in less than 2ms.

2

u/Wise-Profile4256 Oct 29 '26

Love the LIMIT 10. Lets get some mileage out of this engine!

1

u/Strict_Treat2884 Oct 28 '26

I wrote something similarly cursed in the game Database Detective, it was fun and I hope I’ll never have to do it again

1

u/Excellent-Baker1058 Oct 28 '26

Do you get the thing coming out of my mind? lol

-3

u/shoyuftw Oct 28 '26

Love when php and sql are getting mixed

2

u/7DBBA101 Oct 28 '26

PHP is just a fancy way to call SQL programs

0

u/Maku-san_ Oct 30 '26

That's not too bad, ours uses dynamic sql with double exec inside and it has shit formatting too