Lior Graf
Lior Graf

Reputation: 163

thousands of db tables VS one huge table

I am trying to develop an application that keeps track of daily stock data. (Each day a new record is created for every stock). There will be around 5000-10000 stock tracked. Then I need to analyze every day, month or other period some stock data, and keep it.

My question is this: Is it better to have an activity table for each stock that will keep the daily activity (each day a new row) or is it smarter to have one huge table that is inserted with 10,000 records everyday for all the stocks? Keep in mind that I need to do batch calculations every day for every stock (calculating moving averages and stuff).

Upvotes: 3

Views: 172

Answers (2)

RMN
RMN

Reputation: 752

Generally you can query single table faster in comparison to joins and multiple queries.

Upvotes: 0

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174477

One table. You might want to partition it by stock ID.

Automatic table creation is almost always a bad idea.

Upvotes: 6

Related Questions