MongoDB vs PostgreSQL: source lines of code compared

The MongoDB vs PostgreSQL comparison on OctoCounts shows side-by-side source line counts for mongodb/mongo and postgres/postgres, counted under the rules and on the dates stated below: files, total lines, code lines, comment lines, blank lines, and per-language totals, pinned to the exact commits listed below.

This page compares the source lines of code (SLOC) of mongodb/mongo and postgres/postgres using cached OctoCounts reports. Code size is not code quality: a larger count only means more source material, not a better or worse project.

As of 2026-11-05, mongodb/mongo contains 10,578,964 total lines (7,617,918 code) across 39,522 files, while postgres/postgres contains 2,934,089 total lines (1,633,584 code) across 4,138 files as of 2026-11-05. mongodb/mongo has about 4.7x the counted code lines of postgres/postgres under the same engine and counting rules. Code size is not code quality: a larger count only means more source material, not a better or worse project.

Metricmongodb/mongopostgres/postgres
Files39,5224,138
Total lines10,578,9642,934,089
Code lines7,617,9181,633,584
Comment lines1,693,528890,258
Blank lines1,267,518410,247
Languages counted5923

Top languages in mongodb/mongo: C++ (33.9% of code), C++ Header (21.3% of code), C Header (15.3% of code). Top languages in postgres/postgres: C (59.4% of code), PO File (25.1% 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 d48ca0a141ad) on 2026-11-05; postgres/postgres was counted at ref master (commit e352ac8c5c90) on 2026-11-05. See the counting methodology for ignored directories and analysis options.

Both reports use the same engine and effective counting rules. Repository declarations, when enabled, are specific to each repository. mongodb/mongo: tokei-15.0.0, policy directories-v1; docs excluded, tests excluded, generated excluded. Excluded directory names: .cache, .generated, .git, .next, __tests__, build, dist, doc, docs, documentation, fixtures, gen, generated, node_modules, target, test, tests, vendor. Ignored languages: none. Repository declarations: off. Exclusions are rule-based; they do not prove that every test, document or generated file was removed. postgres/postgres: tokei-15.0.0, policy directories-v1; docs excluded, tests excluded, generated excluded. Excluded directory names: .cache, .generated, .git, .next, __tests__, build, dist, doc, docs, documentation, fixtures, gen, generated, node_modules, target, test, tests, vendor. Ignored languages: none. Repository declarations: off. Exclusions are rule-based; they do not prove that every test, document or generated file was removed.

About this comparison

Background observations recorded on 2026-09-16; language descriptions here are historical context, not claims about the current filtered shares. Use this page's measured language breakdown for current counts. Repository layout before counting filters: mongodb/mongo is the MongoDB server repository: the database core in C++, with storage engines and third-party libraries vendored in-tree. postgres/postgres is the PostgreSQL source tree: the backend, planner, executor, and client interfaces, written in C. Both are complete database server source trees measured under the rules and on the dates shown above, making this a like-for-like category comparison.

The per-language tables reflect each project's implementation language directly: MongoDB's counted tree is C++-dominated with vendored components contributing further C and C++, while PostgreSQL's is overwhelmingly C — so the language mix here is a direct readout of each codebase's tradition.

MongoDB's count includes vendored storage-engine and dependency code alongside its own server code, while PostgreSQL's single tree has long contained the whole system — meaning the totals include different amounts of third-party material on each side.

Server source size does not measure query performance, throughput, or operational cost for your workload; those depend on the built system, schema, and configuration, none of which appear in these counts.

Sources: mongodb/mongo repository (C++ database server core) · postgres/postgres repository (C database server source tree). Statements verified 2026-09-16.

Evidence and next steps:

Saved reports remain subject to cache cleanup and replacement. Export their JSON for durable citation; live report URLs can change.

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?

As of 2026-11-05, mongodb/mongo contains 10,578,964 total lines (7,617,918 code) across 39,522 files, while postgres/postgres contains 2,934,089 total lines (1,633,584 code) across 4,138 files as of 2026-11-05. mongodb/mongo has about 4.7x the counted code lines of postgres/postgres under the same engine and counting rules. Code size is not code quality: a larger count only means more source material, not a better or worse project.

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 d48ca0a141ad) on 2026-11-05; postgres/postgres was counted at ref master (commit e352ac8c5c90) on 2026-11-05. 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.