现在我有两个选择。
我对所有数据都有相同的架构。该记录代表与主机之间的连接。因此一条记录属于两个主机。现在我执行一次需要获取 1 台主机的连接的操作。我会将记录插入到 h2 中。那么如果host1和host2之间存在连接。每次查询host1的连接时,我已经存储了host1和host2之间的连接。所以当我查询有关host2的信息时。该记录将在表中存储两次。所以我正在考虑为每个主机创建一个表。
这就是困境所在。因为有很多主机。所以如果我为每个主机创建一个表,表的数量将会很大。是更快地查询巨大但只有一张表还是更快地查询大量较小的表?(无连接)
谢谢
Now I have two choices.
I have the same schema for all the data. the record stand for the connection between to hosts.So one record belongs to two hosts. now I do the action that once I need to get the connection of 1 host. I will insert the record in to h2. So if there is a connection between host1 and host2. Every time I query the connections of host1, I have already store the connection between host1 and host2. So when I query the info about host2. the record will be stored twice in the table. So I am thinking about to create a table for each host.
Here is the dilemma. Since there are a lots of hosts. So if I create a table for each host,the quantity of the tables will be huge. Is to query the huge but only one table faster or to query lots of smaller tables faster?(no join)
Thanks
发布评论
评论(1)
对包含大量记录的一张表建立索引是一种可行的方法。如果不这样做,它可能会成为维护的噩梦,而索引将照顾您在表中的搜索速度。另外,假设您有大量记录,在 Sql Server 2008(以及 2005 年)中,您可以 将表划分为单独的文件,这也有助于提高速度。即使不在 sql server 中,将数据保留在同一个表中也是可行的方法,特别是当每个主机的表架构都相同时。
Indexing the one table with lots of records is the way to go. It can become a maintenance nightmare if you don't, and indexing will take care of your search speed in the table. Plus let's assume that you have a huge amount of records, in Sql Server 2008 (and in 2005) you can partition the table into separate files which will help with speed as well. Even not in sql server, keeping the data in the same table is the way to go, especially if your schema for the table is the same for each host.