Why this query is fast

  Рет қаралды 19,369

Hussein Nasser

Hussein Nasser

Күн бұрын

Welcome to another database question. In this question I created a community poll question and provided some answers. All answers can be correct of course but the question is what is the most efficient? this is what I try to explore in this video and compare how different database platforms such as mysql or Postgres differ in those implementations;
Table T with three integer fields A, B and C.
A has a primary key clustered index.
B has a secondary index.
Which query is more likely to be the most efficient?
0:00 Intro
1:00 The Question
3:20 WHERE C BETWEEN 50,50000
5:30 WHERE B BETWEEN 50,50000
13:20 WHERE A BETWEEN 50,50000
Fundamentals of Networking for Effective Backends udemy course (link redirects to udemy with coupon)
network.husseinnasser.com
Fundamentals of Database Engineering udemy course (link redirects to udemy with coupon)
database.husseinnasser.com
Introduction to NGINX (link redirects to udemy with coupon)
nginx.husseinnasser.com
Python on the Backend (link redirects to udemy with coupon)
python.husseinnasser.com
Become a Member on KZbin
/ @hnasr
Arabic Software Engineering Channel
/ @husseinnasser
🔥 Members Only Content
• Members-only videos
🏭 Backend Engineering Videos in Order
backend.husseinnasser.com
💾 Database Engineering Videos
• Database Engineering
🎙️Listen to the Backend Engineering Podcast
husseinnasser.com/podcast
Gears and tools used on the Channel (affiliates)
🖼️ Slides and Thumbnail Design
Canva
partner.canva.com/c/2766475/6...
Stay Awesome,
Hussein

Пікірлер: 58
@peterhahne2035
@peterhahne2035 2 жыл бұрын
Am I missing something or is uniqueness a game breaker here? Since B is not a primary key we have no guarantee on the uniqueness and therefore we might have millions of records between 50 and 50000
@hnasr
@hnasr 2 жыл бұрын
That is a great point for sure 👍
@HarshKapadia
@HarshKapadia 2 жыл бұрын
Oh good point! I didn't even think of that. I was only thinking in terms of the index.
@joseortiz_io
@joseortiz_io 2 жыл бұрын
Good stuff my guy. It’d be great to have some visuals with the type of discussions just to bring the point home. Anyway, I appreciate these videos a lot. Thanks Hussein! 😁
@fastestwaydown
@fastestwaydown 2 жыл бұрын
It's 'analyze table' in PostgreSQL, mostly paired with vacuum as far as I use it :)
@mylorgolden8146
@mylorgolden8146 2 жыл бұрын
I am continuing to Add to my portfolio. As warren Buffet said "be brave when everyone else is fearful ". The stock market ALWAYS recover, so hold for long term and have the stomach for the ride 👍.
@martasenko514
@martasenko514 2 жыл бұрын
Mrs Sarah really is doing a lot of people a genuine favor with her daily signal! I've earned alot also
@franklinwin5588
@franklinwin5588 2 жыл бұрын
saw recommendation but I did not bother chating her up
@erikvelvez8649
@erikvelvez8649 2 жыл бұрын
Wow i'm glad i did. I withdrew my first profit two days ago now I have another ongoing trade with her
@henrikibsen9780
@henrikibsen9780 2 жыл бұрын
The fruitfulness of your trading lies on the account manager or the expert
@devonvan8322
@devonvan8322 2 жыл бұрын
I have been seeing so many recommendations about Mrs Sarah on different platforms trending I think she must be good for people to talk about her
@HarshKapadia
@HarshKapadia 2 жыл бұрын
This was so much fun!
@denifortran5482
@denifortran5482 2 жыл бұрын
nice video, can you make one with the books from bookshelve explaining them?
@owenflanagan3997
@owenflanagan3997 2 жыл бұрын
pretty sure in postgres ANALYZE updates table stats
@ruchikaahujaasm
@ruchikaahujaasm 8 ай бұрын
@hnasr , if possible can you please do some live coding for building backend systems?
@MartinsTalbergs
@MartinsTalbergs 2 жыл бұрын
We can explore internals on primary index built from multiple columns, maybe there is something interesting there
@weathercontrol0
@weathercontrol0 2 жыл бұрын
I think that it's built with just concatenated values of columns
@MartinsTalbergs
@MartinsTalbergs 2 жыл бұрын
@@weathercontrol0 how would you concatenate different data types, like date and uint and enum?
@weathercontrol0
@weathercontrol0 2 жыл бұрын
@@MartinsTalbergs after all, it's all just bytes, I don't think there's a problem concatenating different data types
@MartinsTalbergs
@MartinsTalbergs 2 жыл бұрын
@@weathercontrol0 there should be a problem, because an index has to be built... Naively, sure - they could do basic BTREE of zeroes and ones
@susmitvengurlekar
@susmitvengurlekar 2 жыл бұрын
IF, A was not a primary key but had a clustered index , then what ? Once you find page for value 50 by doing a primary index scan for the value you got from A's index, every consecutive items in the page and the consecutive pages will have the required data (since it's clustered). BUT, is the database smart enough to know that it doesn't need to scan the primary index for each of the values which it finds in A's index ?
@essamolwan539
@essamolwan539 2 жыл бұрын
Nice haircut. You look good.
@abcdef-bz7ew
@abcdef-bz7ew 2 жыл бұрын
First to comment
@sembo4440
@sembo4440 2 жыл бұрын
Are you uzbek?
@oleksandrlytvyn532
@oleksandrlytvyn532 2 жыл бұрын
Hello, Just watched your video course on HA Proxy --> it's really good quality content. Thanks a lot for doing it 🙂
@gyroninjamodder
@gyroninjamodder 2 жыл бұрын
There's a typo in your chapter titles btw
@hnasr
@hnasr 2 жыл бұрын
Thanks fixed!
@lqx7
@lqx7 2 жыл бұрын
Early
The Lifecycle of an HTTP Request in NodeJS
30:18
Hussein Nasser
Рет қаралды 25 М.
Smart Sigma Kid #funny #sigma #comedy
00:19
CRAZY GREAPA
Рет қаралды 9 МЛН
2000000❤️⚽️#shorts #thankyou
00:20
あしざるFC
Рет қаралды 15 МЛН
World’s Deadliest Obstacle Course!
28:25
MrBeast
Рет қаралды 65 МЛН
Why create Index blocks writes
11:16
Hussein Nasser
Рет қаралды 11 М.
Distributed Transactions are Hard (How Two-Phase Commit works)
16:24
Hussein Nasser
Рет қаралды 31 М.
Avoid premature Database Sharding
20:29
Hussein Nasser
Рет қаралды 15 М.
What is ETL | What is Data Warehouse | OLTP vs OLAP
8:07
codebasics
Рет қаралды 403 М.
Power Query - Faster & Easier Parameters
13:38
BCTI
Рет қаралды 32 М.
How do indexes make databases read faster?
23:25
Arpit Bhayani
Рет қаралды 50 М.
Database Indexing for Dumb Developers
15:59
Laith Academy
Рет қаралды 41 М.
Redo, Undo and WAL logs | The Backend Engineering Show
40:41
Hussein Nasser
Рет қаралды 8 М.
Best Practices Working with Billion-row Tables in Databases
13:41
Hussein Nasser
Рет қаралды 65 М.
SQL performance tuning and query optimization using execution plan
49:23
КОПИМ НА АЙФОН В ТГК АРСЕНИЙ СЭДГАПП🛒
0:59