@stevencodes.swe: This innocent SQL query brought our API to its knees. 47 seconds to count 5 million rows?? The Postgres gotcha that every developer needs to know about MVCC #tektok #coding #software #programming

stevencodes | SWE🧑🏻‍💻
stevencodes | SWE🧑🏻‍💻
Open In TikTok:
Region: US
Monday 28 July 2025 21:06:11 GMT
31413
1699
71
54

Music

Download

Comments

patricq2
Patrick :
Dont use *, use a field in the table in the count function. I find its faster
2025-07-28 21:25:52
17
skywhale405
Skywhale405 :
how does one reach such level 😭😭😭😭.
2025-07-28 21:15:15
61
jimbobzpro
Progardenz :
If all 20 connections were taken up and you were worried about 21 failing, I doubt you can blame it all on the dodgy count(*) when you’ve got 19 other connection hogging requests too..unless they were all doing the same query 😱
2025-07-28 22:21:45
3
foreverzionist
Marcus :
what's that UI at 00:30?
2025-07-29 00:44:16
0
t__cho
T__Cho :
Is this the same on other SQL DB’s? Or only on Postgres?
2025-07-28 21:11:36
6
farazmk83
3D G33K :
just set isolation level to read uncommitted. You dont need repeatable read/read committed for this query
2025-07-28 22:16:48
5
spacecitycardboard
SpaceCityCardboard :
so uh .. this wouldn't be the case in snowflake right
2025-07-28 22:02:39
2
vividream88
viviDream :
your content feel more genuine than anyone on this app even though I understand only like half of it
2025-07-28 21:20:03
12
somestrangescotsman
user8589637753373 :
there must be a better way
2025-07-29 01:12:33
1
omgerez
Erez :
caching is the best option cause you can never know what query will be introduced. naturally try to avoid non indexed queries
2025-07-29 05:34:19
0
emmanuelmendoza64
Emmanuel Mendoza :
Interesting, in Oracle the stats are auto-updated (except for the indexes which affects the exe plan); good to know postgres does not have that
2025-07-29 05:00:15
0
tera9131
Tera :
Sorry there’s no query hints on Postgres? With nolock ?
2025-07-29 03:16:06
0
amineharrabi_
Amine :
Had this problem before, a 6 million row db , i just migrated it to elasticsearch for api use
2025-07-29 00:38:44
0
ahmedsalmi749
ahmedsalmi749 :
For api which having a pagination result it will take have big issues
2025-07-28 22:02:46
0
xuedideson
雪地 :
with an smart index it should be around 30ms, but will minimal increase every write
2025-07-29 00:30:30
0
weaskhalifa
Mr. Bird Dirt :
Interesting stuff
2025-07-29 02:29:34
0
_._._._._._._._._._00_
user6215221313792 :
Stored columns are probably worth a mention.
2025-07-28 22:48:08
0
richard.keitherson
richard.keitherson :
Why would something like a sequence object not work here, deletions?
2025-07-28 22:05:14
0
sponline81
sponline :
the reason we prefer for grid top/limit 500 filter.You don't push all into infront just for paging .
2025-07-29 01:29:29
0
pothaytoe
Potato :
use ProxySQL
2025-07-28 21:23:28
0
padubya
Phillip 🇨🇦 :
👍👍👍
2025-07-28 23:59:00
1
jeroen9
Jeroen :
or use mysql
2025-07-28 22:07:46
0
oldickdickerson
OlDickDickerson :
I just used txt files, screw databases
2025-07-29 02:50:56
0
wolphje
wolph :
Be careful with limit/offset queries. For complex queries that can easily kill your database 😅
2025-07-29 02:22:26
0
aaron.cowie6
Aaron Cowie :
use a read replica database so that it never impacts the primary database
2025-07-29 02:07:35
0
To see more videos from user @stevencodes.swe, please go to the Tikwm homepage.

Other Videos


About