What Is a 2d Geospatial Indexes in MongoDB?
Indexes legacy planar coordinate pairs on a flat 2D plane. It is different from spherical GeoJSON 2dsphere indexing.
How the 2d Geospatial Indexes Algorithm Works
Indexes legacy planar coordinate pairs on a flat 2D plane. It is different from spherical GeoJSON 2dsphere indexing.
When to Use 2d Geospatial Indexes
Legacy planar coordinate applications that intentionally use the supported coordinate representation.
How to Create a MongoDB 2d Geospatial Indexes
Review data quality, existing structures, feature support, build time, and deployment requirements before creating an index on a production table.
db.legacyPoints.createIndex({ point: "2d" })2d Geospatial Indexes Query Example
This example demonstrates the matching query shape. Check the execution plan to confirm that the engine can use the index.
db.legacyPoints.find({ point: { $near: [40, 5] } }).limit(10)Queries Supported by 2d Geospatial Indexes
Legacy planar coordinate applications that intentionally use the supported coordinate representation. A similar-looking predicate may not use the same access path; operators, expressions, key order, and data type all matter.
Read Performance, Storage, and Write Costs
It is inappropriate for Earth-scale spherical calculations and has coordinate/operator constraints. Indexes reduce some search work but require storage and add maintenance to writes.
2d Geospatial Indexes Limitations and Common Mistakes
Use 2dsphere for geographic longitude/latitude and GeoJSON unless a documented legacy case requires 2d.
Do not assume that an index being present means the optimizer chose it or that the query became selective.
How to Measure and Tune 2d Geospatial Indexes
Confirm coordinate model, units, operators, and server release; inspect the explain plan.
Compare representative plans and timings before and after, including concurrent writes and realistic data volumes.
2d Geospatial Indexes Questions
Will the database always use this index?
No. The optimizer weighs selectivity, estimated costs, statistics, cache state, and the amount of data returned.
What should I verify before production?
Confirm version support, query compatibility, write overhead, build/rollback procedures, and index behavior during backup and recovery.
Official MongoDB Index Documentation
Check MongoDB documentation: Index Types for release-specific requirements and supported operators.