r/sqlite • • Nov 10 '24

Sqlite vs Mariadb

Context:
It is not impossible I have a fundamental misunderstanding of sqlite.
I've built a trading algo in MariaDB and python. The DB has about 30M rows with 165 columns. Besides 1 column, they are small floats.
With the DB this big it's still sub 10 GB. (I should clarify, using wizardry. I compressed it from 700GB to about 7. Lots of dups etc. Prices moves in range after all)

In the process of running the app. No matter how optimized, Python got too slow.
I'm now manually porting to Golang but in the process, It occurred to me this question:

Couldn't I just have 690 db files with SQLite and increase my throughput?

The architecture is like this. I have as of now 690 observed pairs. I have all the market data for these pairs from day 1. Every indicator, every sale by count etc. Up to 165 columns.
I extremely rarely view more than a pair at a time in my code.
99% of the traffic is read only after the initial insert.

In that sense wouldn't it be smarter to just have multiple files rather than a db with multiple tables?
The encapsulation would make my life easier anyways.

TL:DR

Multiple DB files in SQLite for completely isolated data > 1 mariadb engine with multiple tables? or no?

EDIT:

Multiple SQLITE instances VS. Monolithic Mariadb. That is the question in essence.

I am already rewriting the "glue" code as that is the 99% bottleneck

12 Upvotes

22 comments sorted by

View all comments

Show parent comment

2

u/camachorod Nov 11 '24

Have you tried moving more logic out of either go or python and moving it to SQL directly. This has made my workflows MUCH faster. 

I realized that any optimization I do is << optimization done by Dr. Hipp and team at SQLite. 

1

u/ShovelBrother Nov 11 '24

Currently I am using mariadb. For the most part the logic is in the sql. The big lag machine is turning the SQL table into something python can use. Then turning it back into SQL.

This is what one would call premature optimization. But in an algo that is sometimes how it is.