No video

Complete MongoDB Tutorial #24 - Indexes

  Рет қаралды 83,333

Net Ninja

Net Ninja

Күн бұрын

Hey gang, in this mongodb tutorial we'll talk about indexes and see how to create them.
🐱‍💻 View this course & other premium courses without ads on the Net Ninja Pro site:
net-ninja-pro....
🐱‍💻 Access the course files on GitHub:
github.com/iam...
(lesson code available from lesson 15 onwards)
🐱‍💻 Modern JavaScript Course:
On Net Ninja Pro - netninja.dev/p...
On Udemy - www.thenetninj...
On KZfaq - • Modern JavaScript Tuto...
🐱‍💻 Node.js Crash Course:
On Net Ninja Pro - netninja.dev/p...
On KZfaq - • Node JS Tutorial for B...
🐱‍💻 VS Code - code.visualstu...
🐱‍💻 Download MongoDB - www.mongodb.co...

Пікірлер: 43
@StevenSokulski
@StevenSokulski 2 жыл бұрын
I think you've mis-used .createIndex() here. { rating: 8 } is analogous to { rating: 1 }, which is an ascending index on the rating field. (-1 would be descending.) You needn't specify a value for the field that you are indexing on. The index encompasses all values.
@daretobedangerous6552
@daretobedangerous6552 Жыл бұрын
ya I was also confused on that part, thanks.
@iatheman
@iatheman Жыл бұрын
Based on the video, I was going to ask if we had to create indexes for all ratings (or whatever values are valid for a property in a collection). Thanks for clarifying it's not needed.
@dfdfdfdfddfdfdfdfdf9140
@dfdfdfdfddfdfdfdfdf9140 Жыл бұрын
Thank you guy for clarifying it, I was messed up with this "8" while reading Mongo documentation.
@hamza-325
@hamza-325 Жыл бұрын
Thanks for pointing this out. I was confused too because I saw that _id is indexed with value of 1 (which means include), so I was wondering why this one is using 8?!
@redpillsatori3020
@redpillsatori3020 Жыл бұрын
@@hamza-325 Should be something like if you want asc order: BookSchema.index({ rating: 1 }, { name: 'rating_8_index', partialFilterExpression: { rating: 8 } });
@jackwagstaffe9895
@jackwagstaffe9895 Жыл бұрын
I'm a bit disappointed to see you ignoring all the comments explaining that this tutorial is incorrect and responding to more recent positive comments
@omsalpekar8876
@omsalpekar8876 Жыл бұрын
true :(
@piotrjan2927
@piotrjan2927 2 жыл бұрын
I am not sure if this explanation is correct. Usually we create indexes for the entire domain of values. db.books.createIndex({rating:1}) will sort in the ascending order, and db.books.createIndex({rating:-1}) in descending order. I do not know if it supports partial indexes only for a specific field value.
@StevenSokulski
@StevenSokulski 2 жыл бұрын
Yep. You're absolutely right. This is easy enough to test. If you make and index on ratings: 8 and then do a query for ratings: 1 you'll see that the same index is used AND that the total records evaluated are equal to the number that are returned.
@MuhammadSaaddev
@MuhammadSaaddev Жыл бұрын
thank you so much sensei for all your efforts..! I'm a proud learner ! While creating indexes, we don't have to specify any column with some specific value rather the docs suggests that indexes should be used as following : db.books.createIndex({rating: 1}) where 1 refers to ASC and -1 refers to DESC order. execution stats clearly shows the difference in execution.
@bovineox1111
@bovineox1111 2 жыл бұрын
Just looking on KZfaq for a MongoDB index tutorial and delight to hear the voice of The Net Ninja and be like oooooh, this guy covers MongoDb.... yoink. Thanks for this.
@malcolmfairs7752
@malcolmfairs7752 2 жыл бұрын
Great Video Shaun. As an Oracle DBA learning MongoDB, I particularly liked the section on indexes and explain('executionStats') to see if its using an index or doing a full scan. Thanks very much for this series. For very big collections, partitions would be worth considering too.
@bkatsevych
@bkatsevych Жыл бұрын
this is probably the best short explanation of mongodb indexes
@NetNinja
@NetNinja Жыл бұрын
Thanks Bohdan!
@tomervainshtein5863
@tomervainshtein5863 10 ай бұрын
Thank you so much! came here from the garbage mongodb "university" course to get things straight. Great stuff, keep it up!
@donatusbrainokwe4350
@donatusbrainokwe4350 2 жыл бұрын
My favorite teacher. Thanks man ❤️
@bakarymtraore6869
@bakarymtraore6869 Жыл бұрын
This is the best mongo DB tutorial thanks dude
@Rohitsingh2410
@Rohitsingh2410 Ай бұрын
can we have multiple indexes? lets say for same collection, an a book id and book rating?
@aiyushbedi
@aiyushbedi 2 жыл бұрын
Love the tutorials 😍. Thanks for creating this series, can you please expand it for Type script and optimising Mongo queries
@zakaria5775
@zakaria5775 Жыл бұрын
Perfect explaining, thanks a lot 🙏🏻!
@NetNinja
@NetNinja Жыл бұрын
Glad it was helpful!
@ryanchristiansacdalan7104
@ryanchristiansacdalan7104 2 жыл бұрын
Thank you Shaun!
@Tony_stark551
@Tony_stark551 2 ай бұрын
Is this playlist completely here??
@NanduriSree
@NanduriSree 2 жыл бұрын
How can i find the difference of Timestamp field for two documents in the given collection where msgID field is same in both documents in the same collection.
@patrikfiala498
@patrikfiala498 2 ай бұрын
@abdellahiaioun8430
@abdellahiaioun8430 9 ай бұрын
Thank you
@farhanmirza52
@farhanmirza52 6 ай бұрын
thank you
@xplore2000
@xplore2000 2 жыл бұрын
Hello there Sir greetings. Could it be possible for me to ask you a question, when ever I got stuck on implementing something?
@coderkashif
@coderkashif 10 ай бұрын
Great
@SaiBaba-zi5my
@SaiBaba-zi5my 7 ай бұрын
If I am not wrong, Indexing is similar to sorting!!
@jhonlee788
@jhonlee788 2 жыл бұрын
First , Thank you for all these lessons ! and i wanted to ask u a question , is it better and less expensive to use mongoDb self hosted than mongoDb Realm for a React Native app ? Thanks in advance !
@AdhimaFauzan
@AdhimaFauzan Жыл бұрын
if you need offline first application, then use Realm
@quangminh7474
@quangminh7474 5 ай бұрын
if I want both offline and online. How can I use sir? @@AdhimaFauzan
@Pareshbpatel
@Pareshbpatel 5 ай бұрын
{2024-02-29}
Complete MongoDB Tutorial #25 - MongoDB Atlas
7:24
Net Ninja
Рет қаралды 112 М.
Learn MongoDB in 1 Hour 🍃 (2023)
1:00:00
Bro Code
Рет қаралды 1 МЛН
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 3,3 МЛН
Bony Just Wants To Take A Shower #animation
00:10
GREEN MAX
Рет қаралды 7 МЛН
English or Spanish 🤣
00:16
GL Show
Рет қаралды 6 МЛН
We NEED To Talk About The War Within
24:51
Bellular Warcraft
Рет қаралды 247 М.
microsoft doubles down on recording your screen
10:00
Low Level Learning
Рет қаралды 81 М.
MongoDB Internal Architecture
43:25
Hussein Nasser
Рет қаралды 85 М.
HIMARS ПО КУРСКОЙ АЭС. СЕРГЕЙ ПЕРЕСЛЕГИН
33:56
СОЦИОСОФТ.ТВ
Рет қаралды 118 М.
Grouping in mongodb
24:51
Hitesh Choudhary
Рет қаралды 27 М.
MERN Stack Tutorial #11 - Adding React Context
26:31
Net Ninja
Рет қаралды 76 М.
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 3,3 МЛН