patternsqlMinor
Stock price database optimization in MySQL
Viewed 0 times
pricestockdatabaseoptimizationmysql
Problem
I am downloading a bulk of stock data:
Ticker symbol, company name, industry sector,
Open, high, low, close
I was wondering performance-wise if separating the ticker, company name, industry sector
from the price data would be optimal, as the tickersymbol and companyname just repeat over and over again.
Or would inner joining the ticker+price every time be slower?
So:
Ticker symbol, company name, industry sector,
Open, high, low, close
I was wondering performance-wise if separating the ticker, company name, industry sector
from the price data would be optimal, as the tickersymbol and companyname just repeat over and over again.
Or would inner joining the ticker+price every time be slower?
So:
- single table (ticker/price), or
- two tables (ticker)(price)?
Solution
Storing the data in one table is not necessarily faster. If you move company name and industry out of the table, each row will be smaller. Smaller rows means more rows per data page. And that means fewer data pages.
You can have a situation where the rows with the company name would be larger than memory. But the pages without the company name would fit in memory. Clearly, the latter situation will result in faster queries.
However, to even begin answering questions about performance, one needs information about the types of queries being run. This will inform not only the table structure, but also the indexes and data types that might be necessary.
You can have a situation where the rows with the company name would be larger than memory. But the pages without the company name would fit in memory. Clearly, the latter situation will result in faster queries.
However, to even begin answering questions about performance, one needs information about the types of queries being run. This will inform not only the table structure, but also the indexes and data types that might be necessary.
Context
StackExchange Database Administrators Q#61570, answer score: 3
Revisions (0)
No revisions yet.