@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
Dont use *, use a field in the table in the count function. I find its faster
2025-07-28 21:25:52
17
Skywhale405 :
how does one reach such level 😭😭😭😭.
2025-07-28 21:15:15
61
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
Marcus :
what's that UI at 00:30?
2025-07-29 00:44:16
0
T__Cho :
Is this the same on other SQL DB’s? Or only on Postgres?
2025-07-28 21:11:36
6
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 :
so uh .. this wouldn't be the case in snowflake right
2025-07-28 22:02:39
2
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
user8589637753373 :
there must be a better way
2025-07-29 01:12:33
1
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
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
Tera :
Sorry there’s no query hints on Postgres? With nolock ?
2025-07-29 03:16:06
0
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 :
For api which having a pagination result it will take have big issues
2025-07-28 22:02:46
0
雪地 :
with an smart index it should be around 30ms, but will minimal increase every write
2025-07-29 00:30:30
0
Mr. Bird Dirt :
Interesting stuff
2025-07-29 02:29:34
0
user6215221313792 :
Stored columns are probably worth a mention.
2025-07-28 22:48:08
0
richard.keitherson :
Why would something like a sequence object not work here, deletions?
2025-07-28 22:05:14
0
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
Potato :
use ProxySQL
2025-07-28 21:23:28
0
Phillip 🇨🇦 :
👍👍👍
2025-07-28 23:59:00
1
Jeroen :
or use mysql
2025-07-28 22:07:46
0
OlDickDickerson :
I just used txt files, screw databases
2025-07-29 02:50:56
0
wolph :
Be careful with limit/offset queries. For complex queries that can easily kill your database 😅
2025-07-29 02:22:26
0
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.