MongoDB vs PostgreSQL: source lines of code compared
As of 2026-07-29, mongodb/mongo contains 11,097,618 total lines (7,938,348 code) across 41,056 files, while postgres/postgres contains 2,932,339 total lines (1,634,362 code) across 4,137 files as of 2026-07-27. mongodb/mongo is about 4.9x 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 | postgres/postgres |
|---|
| Files | 41,056 | 4,137 |
| Total lines | 11,097,618 | 2,932,339 |
| Code lines | 7,938,348 | 1,634,362 |
| Comment lines | 1,840,569 | 887,435 |
| Blank lines | 1,318,701 | 410,542 |
| Languages counted | 12 | 12 |
Top languages in mongodb/mongo: C++ (32.3% of code), C++ Header (20.7% of code), C Header (14.7% of code). Top languages in postgres/postgres: C (59.5% 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 c4bd79565e92) on 2026-07-29; postgres/postgres was counted at ref master (commit b8d9cf512c12) on 2026-07-27. See the counting methodology for ignored directories and analysis options.
Evidence and next steps:
Note: code size is not code quality. OctoCounts only reports reproducible line counts and makes no claim that either project is better.