@greghogg5: SQL queries are not executed in the same order that they are written by the programmer. The database engine follows a specific sequence to filter and organize the data efficiently. It starts with the FROM and JOIN clauses to identify the tables and combine the data. Next it applies the WHERE clause to filter out individual rows that do not meet the criteria. The GROUP BY clause then gathers the remaining rows into summary groups. The HAVING clause is applied after grouping to filter those specific groups. Only after these steps does the SELECT clause run to determine which columns to display. The DISTINCT keyword is then used to remove any duplicate rows from the results. The ORDER BY clause follows to sort the final list in a specific direction. Finally the LIMIT or OFFSET clauses are applied to return the exact number of rows requested.

Greg Hogg
Greg Hogg
Open In TikTok:
Region: CA
Tuesday 12 May 2026 16:03:37 GMT
74371
4295
35
198

Music

Download

Comments

tdirtoktik
TdirTokTik :
This is interesting and educative but apart from that is not use at all. All engines will do those optimizations automatically for you before execution
2026-05-12 21:44:46
28
mauriciogvieira
Maurício :
if the WHERE mentions the table mentioned in FROM it is executed before the join
2026-07-18 08:25:17
2
rumplestiltskin05
Rumplestiltskin :
I hope my gpt 5.5 knows this
2026-05-14 02:24:16
24
jakob_val
Jakob Schulz :
Those optimizations will do nothing. A push down is a very basic operation basically every execution engine will do.
2026-05-12 17:14:28
17
user2480804591279
user2480804591279 :
should the second query not be an inner join?
2026-06-28 07:59:07
0
trex36167
trex :
This has nothing to do with system design
2026-07-19 14:03:38
4
suhremate
suremate :
Afaik the optimizer will handle the join vs where case.
2026-06-10 04:48:06
3
abc050k
James :
why dont the syntax create following the execution order?
2026-05-13 21:25:28
3
skiftcha
Андрей :
why talking about performance not showing execution plan
2026-05-25 01:46:08
2
hanz.1016
hanz :
im pretty sure your left joins wont give the same result
2026-06-25 03:42:45
1
josephmbuthia875
JM :
when you include order table in your where clause you unintentional convert your left join to inner join
2026-07-17 17:56:51
1
iamklevy
iamklevy :
Great!
2026-05-13 00:18:49
0
steelbond
steelbond :
well, duh
2026-05-13 02:02:54
0
user27854955
Chung Heon :
I feel like just always filter then do whatever. that's like the only thing that you needed to know
2026-05-14 07:23:58
2
bizwise
BizWise :
Insightful
2026-07-03 10:33:25
0
sql
@sql :
thanks
2026-05-22 19:12:56
0
fullmoonyeah
AJ P :
nah. its always in the use case. dont always rely on this kind of advise
2026-05-23 07:24:02
0
ssnezzyyy
Banana :
keep create content like this, optimalization is so underated
2026-06-08 00:02:05
0
upsidedown3032
. :
But on The second example, the joins arent interchangeable. Select * from table1 t1 Left join table2 t2 on t1.column1 = t2.column1 and t2.column3=xzy is not the same as Select * from table1 t1 Left join table2 t2 on t1.column1 = t2.column1 where t2.column3 = xzy. They will yield different results…
2026-07-20 17:44:57
0
greatest.comeback22
Greatest Comeback Reviews :
well done
2026-05-13 02:24:41
0
riskminimal
ABU :
i just use AI these days, they make better sql prompts
2026-05-13 12:30:07
0
kashif.ahmed464
kashif ahmed :
distinct?
2026-05-13 08:21:09
0
m_musica
Rafael Deras :
I kinda do filtering in the Join but since I don't see too many people doing it, I thought my way was worse 🙃
2026-05-13 03:55:28
0
cyber.investigations
Cyber Investigations Podcast :
😁
2026-05-13 12:45:30
0
hellona284
hellona :
💙💙💙
2026-05-26 22:40:59
0
To see more videos from user @greghogg5, please go to the Tikwm homepage.

Other Videos


About