Тёмный

Eloquent Where ENUM vs Int Foreign Key: Speed Benchmark 

Laravel Daily
Подписаться 141 тыс.
Просмотров 4,8 тыс.
50% 1

An experiment investigation I had in one demo project, with unexpected results.
Full premium tutorial: laraveldaily.com/post/eloquen...
- - - - -
Support the channel by checking out my products:
- My Laravel courses: laraveldaily.com/courses
- Filament examples: filamentexamples.com
- Livewire Kit Components: livewirekit.com
- - - - -
Other places to follow:
- My weekly Laravel newsletter: us11.campaign-archive.com/hom...
- My personal Twitter: / povilaskorop

Хобби

Опубликовано:

 

2 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 32   
@trispretty
@trispretty 10 дней назад
This was fascinating, cheers! I'm a life time member, I'm going to dive into this. Great research!
@jeremyvanderwegen1467
@jeremyvanderwegen1467 9 дней назад
Thanks, learned that we can also use multiple column indexes!
@mohammadsalloum1
@mohammadsalloum1 9 дней назад
Thanks, very useful.
@wgblondel
@wgblondel 9 дней назад
Haha, funny to see you doing this experiment too. Few months ago I wanted to experiment using Filament with a huge amount of data, so I cloned the Filament demo and seeded millions of records. The first challenge was to rewrite the seeders and factories in a way that the seeding process doesn't take ages to complete ... 😁 Then I had to optimize some SQL queries, and I noticed the same problem with the deleted_at fields. Had to add some indexes to improve the overall performance.
@e.nelson
@e.nelson 8 дней назад
My other issue with filament is that bulk selecting data on a resource table takes ages to hydrate, even worse when you want you to load a form to perform data on these deleted records.
@JohnRoux
@JohnRoux 6 дней назад
@@e.nelson Yeah, the bulk select will do a count*, so at 5m rows+, it's really not a great option. I end up swapping to only allowing the bulk select for this page. You also need to swap to simple pagination to avoid that count query though
@youneschibouti4555
@youneschibouti4555 9 дней назад
great work, thank you
@laubannenberg5446
@laubannenberg5446 9 дней назад
At first I thought this was going to be about PHP enums with casts, not sql enums. It might be interesting to dive deeper into the pros and cons of using only PHP enums (design flexibility?) or only sql enums (performance? ) or both. And yeah, it makes sense soft deletes should be a BIG consideration for your use of indexes.
@LaravelDaily
@LaravelDaily 9 дней назад
PHP enums would have been my next step with status_number field without foreign key, but since it didn't give any performance benefits, I didn't pursue it further.
@hurleyd9828
@hurleyd9828 9 дней назад
Awesome video
@JohnRoux
@JohnRoux 6 дней назад
Another option/improvement here is to make a virtual Stored column for `is_deleted`, a tinyint notnull (boolean) that is computed from (deleted_at IS NOT NULL) Then you index that column. You get around the issue with nullable columns, plus your index size is far smaller. It's very seldom you need to check if it was deleted before X date, and those times you can look at the `deleted_at`. But 99% of the time your query is going to be just caring about that boolean value
@LaravelDaily
@LaravelDaily 6 дней назад
In theory, I agree with you. But I've tested a similar scenario, and "where is_deleted = 0" and "where deleted_at is null" had identical performance, when both indexed. Didn't check the index size, though, maybe there is a slight benefit there, to save some disk space.
@JohnRoux
@JohnRoux 6 дней назад
@@LaravelDaily yeah, I suspect the difference here will be the not null covering and index size If there's only 1 nullable Field in the index, as the last index, then it definitely won't make any performance impact, though that index might be a lot smaller
@lazycode258
@lazycode258 9 дней назад
Good day! Do you have any laravel tutorials that employ this vue3, type script, pinia, and axios?
@LaravelDaily
@LaravelDaily 9 дней назад
No, sorry
@DoonSafari
@DoonSafari 10 дней назад
Hi, Please make a video series on system design video for a Laravel project.
@LaravelDaily
@LaravelDaily 10 дней назад
"system design video"? What do you mean exactly, can you rephrase?
@user-wz5ui7ce7p
@user-wz5ui7ce7p 8 дней назад
​@LaravelDaily I guess he talk about something like common architectural things such as architectural layers, business domain separation from framework etc. As Laravel developer, I also would like to know how we can build Laravel API with best architectural tips. I guess in "Laravel world" we choose our own philosophy with some features and solutions, but maybe we still have other approaches for architectural things?
@vlatkoviamkd
@vlatkoviamkd 9 дней назад
Please make a video for Computed properties in Livewire and be more detailed, like the last video of Josh Cirre in "Which Livewire method should I use?".
@LaravelDaily
@LaravelDaily 9 дней назад
I think it's all pretty clear in the docs, my video wouldn't add something significant.
@vlatkoviamkd
@vlatkoviamkd 9 дней назад
@@LaravelDaily maybe When to use computed properties, difference in performance and cashing with computed properties. And when NOT to use them. But either way very much appreciate your work, you are the best.
@LaravelDaily
@LaravelDaily 9 дней назад
In my experience I didn't feel much difference, to be honest. I would need someone to code me a demo project that I would be able to debug and compare. Too much work for too niche topic.
@ultrasys
@ultrasys 9 дней назад
I didn’t have the patience to finish watching the video, but I would like to share that every time I heard “tiny int”, my ears screamed in pain. There’s something called padding, and it costs in terms of processing. Padding is bad for performance even if you think l it is just a matter of applying a simple calculation. The problem with it is that processors are much more efficient in loading and transferring data in their “native” block size (and this depends on what operation is being done), generally (today, at least) 64bits. Not “tiny” at all. Add to that, the weak MySQL code base, which, to me, looses only to MS SQL Server.
@abdullajonsharipov6504
@abdullajonsharipov6504 7 дней назад
If not enum, column type varchar and index then ?
@LaravelDaily
@LaravelDaily 7 дней назад
Have you watched the video?
@Ali-hh9oi
@Ali-hh9oi 8 дней назад
It's obviously slower because you did it wrong, you had to make a constant class of statuses (different file for each entity status, for eg TransactionStatus, ShopStatus, etc) instead of saving that on DB
7 дней назад
What you mean?
@keenj
@keenj 6 дней назад
He used $table->enum not classes. What are you talking about?
@Fosterushka
@Fosterushka 6 дней назад
bruh, sql query have nothing todo with php
@LaravelOnline
@LaravelOnline 6 дней назад
Umm…. No…
@373323
@373323 9 дней назад
wow
Далее
14 Quick Laravel Tips in 9 Minutes: May 2024
9:09
Просмотров 9 тыс.
Best father #shorts by Secret Vlog
00:18
Просмотров 13 млн
The most powerful way to use Eloquent
11:51
Просмотров 3,8 тыс.
`const` was a mistake
31:50
Просмотров 128 тыс.
Getting Started with Event Sourcing in .NET
37:07
Просмотров 51 тыс.
Ladybird browser update (June 2024)
18:17
Просмотров 25 тыс.
Why Don't We Have A Laravel For JavaScript?
12:36
Просмотров 89 тыс.
Stop the Flexbox for 1D, Grid for 2D layout nonsense
10:22
18 Laravel/PHP Tips in 10 Minutes: June 2024
10:41
Просмотров 8 тыс.
Don't Use Polly in .NET Directly. Use this instead!
14:58
EQUIPAMENTOS TOP ? #moto  #motopeças
0:13
Просмотров 21 млн