This article is suitable for users who have some knowledge about mongodb. Mongodb data files are stored in the directory specified by the dbpath option. Each database has a series of Files: dbname. ns, dbname.0, dbname.1,... the data file is also called pdfile, meaning PortableDataFile. Dbname. ns file dbname. ns file storage name is blank
This article is suitable for users who have some knowledge about mongodb. Mongodb data files are stored in the directory specified by the dbpath option. Each database has a series of Files: dbname. ns, dbname.0, dbname.1,... the Data File is also called pdfile, meaning Portable Data File. Dbname. ns file dbname. ns file storage name is blank
This article is suitable for users who have some knowledge about mongodb.
Mongodb data files are stored in the directory specified by the dbpath option. Each database has a series of Files: dbname. ns, dbname.0, dbname.1,... the Data File is also called pdfile, meaning Portable Data File.
Dbname. ns File
Dbname. ns file storage namespace information. In mongodb, each collection has a namespace named dbname. collection_name. The dbname. ns file stores an array of hash table nodes. The key is based on the namespace name, and the value is the namespace information. The size of the hash table node is 628 bytes, and the Hong Kong server is rented. The default size of the dbname. ns file is 16 Mb. The Hong Kong VM can store a total of 26715 namespaces. The nssize option can be used to set the size of the dbname. ns file.
Related code
Dbname. <#> series files
Dbname. <#> A series of files store all the data in each database. The file format is
--------------------------------------------
DataFileHeader
--------------------------------------------
Extent (for a participant namespace)
Record
...
Record (some chained for unused space)
--------------------------------------------
More Extents...
--------------------------------------------
DataFileHeader is the header of the data file, followed by Extent. The file space is allocated in Extent. The Applied Extent of each namespace forms a two-way linked list. The header and end of the table are included in the namespace information. Record is a Record, which is allocated in Extent. All records in each Extent form a two-way linked list. The header and the end of the table have the Extent header. You can think of the following method to traverse all the Record in the namespace: traverse the Extent linked list and traverse the Record linked list for each Extent. Idle Record (the remaining space in Extent, or the Record is deleted). The Record-free space is called DeleteRecord. Based on its size, 19 one-way linked lists are formed (the table header also exists in the namespace ). You can think of the method to apply for a Record: First find it from the idle Record; if it cannot be found, allocate a new Extent.
When a namespace is deleted, all its Extent will be mounted to the Extent linked list of the collection named $ freelist. When Extent is allocated, it is first searched from the Extent linked list of $ freelist. If not, apply for a new Extent.
Related code