paint-brush
Javascript: experience of migrating from MongoDB to PostgreSQLby@holdfenytolvaj
6,427 reads
6,427 reads

Javascript: experience of migrating from MongoDB to PostgreSQL

by Géza Radics6mNovember 8th, 2016
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Our project (<a href="http://labcup.net" target="_blank">labcup.net</a>) started as a hobby weekend project and as it is.. naturally a good place to try new technologies, this is how we chose MongoDB circa 2 years ago. The project has grown to a full time work and started to have paying customers as well. Though the experimenting was a right decision back at the time, MongoDB was is clearly the wrong tool for the task now (we have relatively small databases with few users but strong need for consistency).<br>We knew it but had to keep on moving till this summer, when we spent so much time on discovering and fixing <a href="https://hackernoon.com/tagged/database" target="_blank">database</a> inconsistencies that we could not live with it longer, we had to act.<br><em>Note</em>: that inconsistencies arise not from lack of tests, but lack of type checks (or silent conversion), lack of transactions and from wrong assumptions; — unless you check the code, you can only guess about the structure and types.<br><em>Note</em>: the size of the project is around 60K LOC (without comments, according to <a href="https://github.com/AlDanial/cloc" target="_blank"><em>cloc</em></a>) and it is typescript only, so it is definitely not a small project.<br>I also have to mention here, that typescript helped a lot on the type checks and structure definitions but obviously more was needed.<br><em>Note</em>: there were other issues as well with MongoDB. E.g.:<br>- the ObjectId occupied 32 chars which is a lot to send over and store on client side (we cache data on the browser’s indexedDb).<br>- not the biggest issue, but annoying and error prone to always convert the ObjectId for queries (e.g. if string was used for the query, it just silently returned with no result)<br>- some of the mysterious inconsistencies were probably due to surprising index usage, where not all records has been returned. (see here <a href="https://engineering.meteor.com/MongoDB-queries-dont-always-return-all-matching-documents-654b6594a827#.j1n0zyk2d" target="_blank">https://engineering.meteor.com/MongoDB-queries-dont-always-return-all-matching-documents-654b6594a827#.j1n0zyk2d</a> )

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Javascript: experience of migrating from MongoDB to PostgreSQL
Géza Radics HackerNoon profile picture
Géza Radics

Géza Radics

@holdfenytolvaj

L O A D I N G
. . . comments & more!

About Author

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Github
Npmjs
Snyk
Npm
Npmmirror
Skypack