# MongoDB vs PostgreSQL: source lines of code compared

As of 2026-09-07, mongodb/mongo contains 10,421,016 total lines (7,510,293 code) across 38,945 files, while postgres/postgres contains 2,935,030 total lines (1,635,202 code) across 4,141 files as of 2026-09-07. mongodb/mongo is about 4.6x the size of postgres/postgres by code lines. Code size is not code quality: a larger count only means more source material, not a better or worse project.

| Metric | [mongodb/mongo](https://octocounts.com/github/mongodb/mongo) | [postgres/postgres](https://octocounts.com/github/postgres/postgres) |
| --- | ---: | ---: |
| Files | 38,945 | 4,141 |
| Total lines | 10,421,016 | 2,935,030 |
| Code lines | 7,510,293 | 1,635,202 |
| Comment lines | 1,659,930 | 889,139 |
| Blank lines | 1,250,793 | 410,689 |
| Languages counted | 12 | 12 |

Top languages in mongodb/mongo: C++ (33.9% of code), C++ Header (21.6% of code), C Header (15.4% of code). Top languages in postgres/postgres: C (59.4% of code), PO File (25.0% of code), C Header (7.3% of code). C Header, C appear in both top language lists; C++, C++ Header, JavaScript appear only in mongodb/mongo's top languages; PO File, SQL, Perl appear only in postgres/postgres's top languages.

Methodology: both counts come from cached OctoCounts reports generated with tokei. mongodb/mongo was counted at ref master (commit 46014702c278) on 2026-09-07; postgres/postgres was counted at ref master (commit f836b688f8dc) on 2026-09-07. See the [counting methodology](https://octocounts.com/docs/methodology) for ignored directories and analysis options.
Evidence and next steps:

- [mongodb/mongo SLOC report](https://octocounts.com/github/mongodb/mongo)
- [postgres/postgres SLOC report](https://octocounts.com/github/postgres/postgres)
- [Compare mongodb/mongo and postgres/postgres interactively](https://octocounts.com/compare?left=https%3A%2F%2Fgithub.com%2Fmongodb%2Fmongo&right=https%3A%2F%2Fgithub.com%2Fpostgres%2Fpostgres)

Note: code size is not code quality. OctoCounts only reports reproducible line counts and makes no claim that either project is better.

## Compare FAQ

### Which has more lines of code, mongodb/mongo or postgres/postgres?

mongodb/mongo has more code: 7,510,293 code lines versus 1,635,202 for postgres/postgres, about 4.6x as much, based on cached OctoCounts reports as of 2026-09-07.

### Does more source lines of code mean more complexity?

Not necessarily. SLOC measures size, not complexity, quality, or maintainability. A larger codebase can mean more features, more generated or vendored code, more verbose language idioms, or more tests — none of which imply the code is harder to work with. Use SLOC to gauge the scale of what you'd be reading or maintaining, not as a quality signal for mongodb/mongo, postgres/postgres, or any repository.

### How is this comparison calculated?

Methodology: both counts come from cached OctoCounts reports generated with tokei. mongodb/mongo was counted at ref master (commit 46014702c278) on 2026-09-07; postgres/postgres was counted at ref master (commit f836b688f8dc) on 2026-09-07. See the counting methodology for ignored directories and analysis options.

### Can I compare a different branch, tag, or commit?

Yes. This page shows the default branch for each repository. Use the interactive comparison tool to pick any public GitHub repository, branch, tag, or commit SHA for both sides and get a fresh side-by-side report.

## Related OctoCounts pages

- [Interactive repository comparison](https://octocounts.com/compare)
- [Recently analyzed repositories](https://octocounts.com/recent)
- [Popular SLOC reports](https://octocounts.com/popular)
- [Trending GitHub repositories](https://octocounts.com/trending)
- [Hall of Monoliths](https://octocounts.com/hall-of-monoliths)
- [GitHub SLOC counter guide](https://octocounts.com/docs/github-sloc-counter)
- [Counting methodology](https://octocounts.com/docs/methodology)
- [OctoCounts API docs](https://octocounts.com/docs/api)
