SQL-多个表与一个大表 [英] SQL - multiple tables vs one big table

查看:54
本文介绍了SQL-多个表与一个大表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将多个 SQLite 文件移动到 PostgreSQL .

I want to move multiple SQLite files to PostgreSQL.

这些文件中包含的数据为每月 时间序列(单个* .sqlite文件中为一个月).每个都有大约300,000行.这些文件超过20个.

Data contained in these files are monthly time-series (one month in a single *.sqlite file). Each has about 300,000 rows. There are more than 20 of these files.

我的难题是如何组织新数据库中的数据:

My dilemma is how to organize the data in the new database:

a)将其保存在多个表中

b)将其合并到一个大表中,并用新列描述时间段(例如04.2016、05.2016等)

a) Keep it in multiple tables
or
b) Merge it to one huge table with new column describing the time period (e.g. 04.2016, 05.2016, ...)

该数据库将仅用于从中提取数据(添加新月份的数据除外).

The database will be used only to pull data out of it (with the exception of adding data for new month).

我担心的是,从多个表( join )中进行 select 数据的执行效果不佳,查询可能会变得非常复杂.

My concern is that selecting data from multiple tables (join) would not perform very well and the queries can get quite complicated.

我应该使用哪种结构-一个大表还是多个小表?

Which structure should I go for - one huge table or multiple smaller tables?

推荐答案

我想我肯定会去一张桌子-只要确保您使用合理的索引即可.

Think I would definitely go for one table - just make sure you use sensible indexes.

这篇关于SQL-多个表与一个大表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆