Search code examples
mongodbpostgresqlsqliteflat-filedatabase

Database or flat file for millions of records?


Suppose that a tuple of four strings (date, name, type, price) is generated every 10 seconds. I'm writing a program in Python in order to store these tuples in disk for future use (only Read1). There are going to be millions of tuples, so the "insert" operation is crucial here. What's the best solution to this problem? SQLite, Postgres, MongoDB, or flat file?

1 I will read almost all the data in memory, from beginning to end. I don't need complex relational reads. For example, "SELECT price FROM table" is what I need. I won't use any indexes at all.


Solution

  • I would definitely recommend mongo. With indexes you can have very good performance on that set of data. With a flat file, you're going to have to manage all the complexities of a database system in your application logic (assuming you need this data with any form of urgency). If you add an index on the field you're looking to query, you should be fine in the performance category, especially when you're only in the millions of records range.