Postgres gotcha: pg_advisory_xact_lock + SERIALIZABLE.
The snapshot is taken at the first statement: the lock call. Queued txns got the lock, read stale data, and SSI aborted them.
Fix: READ COMMITTED for that txn (the lock serialises it) + retry 40001.๐
#PostgreSQL#Database
@_chrismdavidson Appreciate it! Interesting that you'd go GIN. The article I learned from picked GiST because it needed ORDER BY distance. Do you find GIN + similarity() fast enough for ranking in practice?
Someone types "Michael Louis" into your search bar. The person they want is "Michael Lewis."
Most apps show "no results."
I went down a rabbit hole this week on how Postgres solves this, and how one benchmark made it ~800x faster.
Here's what I learned ๐งต #PostgreSQL
What I'm taking away:
Only need matches? Use GIN.
Need the closest ones ranked? Use GiST.
Always test on your own data.
Learned it from @AlexKlibisz article and @pganalyze's video:
https://t.co/YTxKvHZ3Fy
https://t.co/mcwygDYQeD
#Database#BackendDevelopment
The results from that benchmark (approximate):
No index: ~95s
GiST, small labels: ~4s
GiST, bigger labels: under 2s
Search all 4 columns with one index: ~113ms
Same data, same query idea. Just the right index.
I'm not an election expert, so I'm sure there are gaps I can't see.
Would be really grateful for a review from people who've spent years on this: @nixxin@digitaldutta@jhalderm. Even a quick "this part breaks here" would help a lot.
I've been chewing on one question since the EC debate erupted in the capital: if you had to redesign voter verification in India from scratch, what would you build?
My first idea was "put everything on a blockchain." Mostly wrong, it turns out. Here's where I landed.
Things I dropped from v1 after poking holes in it:
- hashing fingerprints (every scan is slightly different, so it doesn't work)
- storing citizens or votes on-chain
- making Aadhaar mandatory
- "this makes rigging impossible." Nothing does. The goal is making it detectable.