Dab tsi yog indexing MongoDB?
Dab tsi yog indexing MongoDB?

Video: Dab tsi yog indexing MongoDB?

Video: Dab tsi yog indexing MongoDB?
Video: What is a database schema? 2024, Kaum ib hlis
Anonim

Ib qhov ntsuas hauv MongoDB yog cov ntaub ntawv tshwj xeeb uas tuav cov ntaub ntawv ntawm ob peb lub teb ntawm cov ntaub ntawv uas cov qhov ntsuas yog tsim. Index txhim kho qhov nrawm ntawm kev tshawb nrhiav hauv cov ntaub ntawv vim tias tsis yog kev tshawb nrhiav tag nrho cov ntaub ntawv, kev tshawb fawb tau ua nyob rau hauv indexes uas tuav ob peb teb xwb.

Tsis tas li ntawd, dab tsi yog qhov sib xyaw index hauv MongoDB?

MongoDB txhawb nqa cov indexes ,wo ib qhov ntsuas tus qauv tuav cov ntaub ntawv xa mus rau ntau qhov chaw [1] hauv cov ntaub ntawv sau. Daim duab hauv qab no qhia txog ib qho piv txwv ntawm a sib index ntawm ob daim teb: nyem kom loj. [1] MongoDB imposes qhov txwv ntawm 32 teb rau ib qho twg sib index.

indexing hauv database nrog piv txwv yog dab tsi? Index yog siv los nrhiav cov ntaub ntawv sai sai yam tsis tas yuav tshawb nrhiav txhua kab hauv ib database rooj txhua lub sij hawm a database rooj nkag. Rau piv txwv , ib qhov ntsuas tuaj yeem tsim nyob rau sab sauv (last_name), uas tsuas yog khaws cov ntaub ntawv sab saud ntawm lub xeem_name teb hauv qhov ntsuas.

Kuj Paub, qhov ntsuas thib ob hauv MongoDB yog dab tsi?

MongoDB txhawb nqa theem nrab indexes . Tsim ib qho qhov ntsuas , koj tsuas yog qhia cov teb los yog ua ke ntawm cov teb, thiab rau txhua daim teb qhia cov kev taw qhia ntawm cov qhov ntsuas rau thaj teb ntawd; 1 rau ascending thiab -1 rau nqis. Cov hauv qab no tsim ib qho nce qhov ntsuas ntawm kuv teb: collection.

Kuv yuav saib indexes hauv MongoDB li cas?

Rau saib ib daim ntawv teev tag nrho indexes nyob rau hauv ib tug collection MongoDB Compass, nyem rau ntawm lub hom phiaj sau nyob rau sab laug tes pane thiab xaiv cov Index tab.

Pom zoo: