frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

SQL Anti-Patterns You Should Avoid

https://datamethods.substack.com/p/sql-anti-patterns-you-should-avoid
41•zekrom•2h ago

Comments

jwsteigerwalt•30m ago
That’s my rap sheet…
JohnHaugeland•29m ago
these aren’t anti patterns. these are just things you shouldn’t do
em500•26m ago
Still waiting for the definitive article on why using the term anti-pattern is an anti-pattern.
readthenotes1•4m ago
If a pattern is a common problem (e.g., becoming accustomed to a spectacular view) and generally-useful solution to that problem (blocking the view so that effort is required to obtain it), then an anti-pattern is what?

I think most people think an anti-pattern is an aberration in the "solution" section that creates more problems.

So here, the anti-pattern is that people use a term so casually (e.g., DevOps) that no one knows what it's referring to anymore.

(The problem: need a way to refer to concept(s) in a pithy way. The solution: make up or reuse an existing word/phrase to incorporate the concept(s) by reference so that it can can, unambiguously, be used as a replacement for the longer description. )

jacknews•26m ago
"When handling large CASE WHEN statements, it is better to create a dimension table or view, ideally sourced from the landed table where the original status column is populated."

Is this code for 'use a lookup table' or am I falling behind on the terminology? The modern term should be 'sum table' or something similar surely.

LikesPwsh•12m ago
"Dimension table" is the name for lookup tables in a star or snowflake schema.
jacknews•3m ago
Thanks.

'Landed table'?

parpfish•2m ago
but sometimes large case statements cant be turned into a simple dimension table/lookup table because it's not a simple key-value transformation.

if your case statement is just a series of straighahead "WHEN x=this THEN that", you're very lucky.

the nasty case statements are the ones were the when expression sometimes uses different pieces of data and/or the ordering of the statements is important.

jasonpbecker•25m ago
We did the views on view thing once when triggers, at least how we implemented them failed. This became a huge regret that we lived with for years and not-so affectionately called "view mountain". We finally slayed viewed mountain over the last 2 years and it feels so good.
chongli•24m ago
When working with larger enterprise software, it is common to have large CASE WHEN statements translating application status codes into plain English. For example, status code 1 could mean the item is out of stock.

Why wouldn’t you store this information in a table and query it when you need it? What if you need to support other languages? With a table you can just add more columns for more languages!

megaman821•10m ago
I usually use generated columns for this. It still uses CASE WHEN but it is obvious to all consumers of the table that it exists.
anthonyIPH•24m ago
"Instead you should:

query WHERE name = ‘abc’

create an indexed UPPER(name) column"

Should there be an "or" between these 2 points, or am I missing something? Why create an UPPER index column and not use it?

wmonk•18m ago
The section of using functions on indexes could do with more explicit and deeper explanation. When you use the function on the index it becomes a full scan of the data instead as the query runner has to run the function on every row and column, effectively removing any benefit of the index.

Unfortunately I learned this the hard way!

LikesPwsh•15m ago
Some well known docs on the topic- https://use-the-index-luke.com/sql/where-clause/obfuscation
readthenotes1•13m ago
"Unfortunately I learned this the hard way!" ... Seems to be the motto of SQL developers.

Otoh, it seems a fairly stable language (family of dialects?) so finding the pitfalls has long leverage

EvanAnderson•8m ago
> Overusing DISTINCT to “Fix” Duplicates

Any time I see DISTINCT in a query I immediately become suspicious that the query author has an incomplete understanding of the data model, a lack of comprehension of set theory, or more likely both.

Sesse__•4m ago
Or just doesn't know how to do semijoins in SQL, since they don't follow the same syntax as normal joins for whatever historical reason.
dgb23•2m ago
If „select *“ breaks your code, then there‘s something wrong with your code. I think Rich Hickey talked about this. Providing more than is needed should never be a breaking change.

Certain languages, formats and tools do this correctly by default. For the others you need a source of truth that you generate from.

Best xkcd

https://www.heavyconsulting.net/bestxkcd/
1•antitoxic•3m ago•0 comments

The most dangerous corner of a balance-sheet

https://www.economist.com/finance-and-economics/2025/10/08/the-most-dangerous-corner-of-a-balance...
1•hhs•4m ago•0 comments

Hard disk LEDs and noisy machines

https://blogsystem5.substack.com/p/hard-disk-leds-and-noisy-machines
1•FromTheArchives•10m ago•0 comments

Show HN: GPU Rank, a dataset of GitHub repos that utilize heterogenous computing

https://tyler-hilbert.github.io/GPURank/
1•Tyler-Hilbert•13m ago•0 comments

Build Server Protocol

https://build-server-protocol.github.io/
1•znpy•15m ago•0 comments

Australian Climate Risk Assessment issues dire warnings

https://www.wsws.org/en/articles/2025/10/09/ickj-o09.html
2•PaulHoule•15m ago•0 comments

BBC computer literacy project archive

https://clp.bbcrewind.co.uk/
1•fanf2•17m ago•0 comments

Happy International Repair Day 2025

https://www.ifixit.com/News/113812/happy-international-repair-day-2025
1•gnabgib•18m ago•0 comments

Bit banged 100 MBit/s Ethernet transmission on RPi Pico

https://github.com/steve-m/Pico-100BASE-TX
2•metropolis_pt2•18m ago•1 comments

The test for U.S. citizenship is about to get harder

https://www.npr.org/2025/10/16/nx-s1-5566732/the-trump-administration-is-rolling-out-changes-to-t...
1•geox•18m ago•1 comments

The viral new "Definition of AGI" paper has fake citations which do not exist

https://twitter.com/m2saxon/status/1979349387391439198
4•archon1410•19m ago•1 comments

Skillz: Anthropic‑Style Skills for Any MCP Client

https://elite-ai-assisted-coding.dev/p/skillz
1•intellectronica•20m ago•0 comments

Learn Go the Hard Way

https://learncodethehardway.com/emails/21-learn-go-the-hard-way-draft-1-released/
3•ryandotsmith•22m ago•0 comments

TanStack DB: A reactive client store for building super fast apps

https://tanstack.com/db/latest
1•ko_pivot•25m ago•0 comments

Flowistry: An IDE plugin for Rust that focuses on relevant code

https://github.com/willcrichton/flowistry
1•Bogdanp•25m ago•0 comments

Gnome Has a New Security Threat Scanner Powered by VirusTotal

https://www.phoronix.com/news/GNOME-Lenspect-Threat-Scanner
1•rbanffy•28m ago•0 comments

Rare Earths Aren't Rare

https://marginalrevolution.com/marginalrevolution/2025/10/rare-earths-arent-rare.html
1•asplake•28m ago•0 comments

How to Get to Mars

https://sciencefictiontalk.substack.com/p/how-to-get-to-mars
1•HR01•29m ago•0 comments

Marine colonel quits after 24 years citing concern for future of US under Trump

https://www.theguardian.com/us-news/2025/oct/16/marine-resigns-trump-hegseth
3•hypeatei•30m ago•1 comments

Google's AI Cracks a New Cancer Code

https://decrypt.co/344454/google-ai-cracks-new-cancer-code
1•signa11•32m ago•0 comments

Winre Freezes After KB5066835

https://learn.microsoft.com/en-gb/answers/questions/5586986/win11-24h2-winre-freezes-after-kb5066...
1•acqq•35m ago•0 comments

Browsing behavior exposes identities on the Web

https://www.nature.com/articles/s41598-025-19950-3
1•XzetaU8•38m ago•1 comments

SHOW HN: I made a site for 100% location independent jobs too

https://job.careers/
1•lanmao_163•38m ago•0 comments

We are in the "gentleman scientist" era of AI research

https://www.seangoedecke.com/ai-and-informal-science/
2•edanm•39m ago•0 comments

Show HN: Silly Morse code chat app using WebSockets

https://noamtamir.github.io/morwse/
4•noamikotamir•41m ago•0 comments

The Best Way to Learn Might Be Starting at the End

https://interjectedfuture.com/the-best-way-to-learn-might-be-starting-at-the-end/
2•iamwil•43m ago•0 comments

The Future of Attention

https://micro.mu/blog/2025/10/18/the-future-of-attention.html
1•asim•48m ago•0 comments

AI-related data centres use vast amounts of water

https://www.cbc.ca/news/ai-data-centre-canada-water-use-9.6939684
1•cratermoon•49m ago•0 comments

A Random Walk in ℤ⁵

https://gist.github.com/olooney/d98f8e862a11974f36b3620f517df006
2•olooney•49m ago•0 comments

Show HN: Terminal Markdown notes using lockbook's CLI

https://www.youtube.com/watch?v=UwXiAAtgjb8
2•parthmehrotra•50m ago•0 comments