为大量行设计表。没有关系 [英] Designing a table for large amount of rows. No relationships

查看:48
本文介绍了为大量行设计表。没有关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我希望设计一个允许我存储文件引用的数据库。该表非常简单 - >  Id(GUID)(PK),
Path(varchar),IsPublic(bit),FileType(int)


通过将GUID放在url中,可以通过Url访问这些文件,例如  files / {GUID}
所以如果请求进来,我可以通过GUID查询表为PrimaryKey。

The files can be accessed via Url by putting the GUID in the url, such as files/{GUID}, so if request comes in, I can query the table by the GUID as PrimaryKey.


您认为这是一种有效的方法吗?我在查看数亿条记录时的插入/查询性能是什么?

Do you think this is a valid approach? What insert/query performance am I looking at with hundreds of millions of records?


数据库引擎是MS SQL Server。

The database engine is MS SQL Server.


编辑:我预测的一些查询:

Some queries I am predicting:


<代码样式="保证金:0px;填充:1px 5px;边框:0像素;字体风格:继承;字体变:继承;字体重量:继承;行高:继承; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;字体大小:13像素;垂直对齐:基线;背景色:#eff0f1; white-space:pre-wrap"> SELECT
* FROM Files其中ID = {GUID}


<代码样式="保证金:0px;填充:1px 5px;边框:0像素;字体风格:继承;字体变:继承;字体重量:继承;行高:继承; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;字体大小:13像素;垂直对齐:基线;背景色:#eff0f1; white-space:pre-wrap"> INSERT
INTO Files()VALUES()


<代码样式="保证金:0px;填充:1px 5px;边框:0像素;字体风格:继承;字体变:继承;字体重量:继承;行高:继承; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;字体大小:13像素;垂直对齐:基线;背景色:#eff0f1; white-space:pre-wrap"> UPDATE
文件SET IsPublic = true WHERE ID = {GUID}


<代码样式="保证金:0px;填充:1px 5px;边框:0像素;字体风格:继承;字体变:继承;字体重量:继承;行高:继承; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;字体大小:13像素;垂直对齐:基线;背景色:#eff0f1; white-space:pre-wrap"> UPDATE
文件SET Label = {NewLabel} WHERE ID = {GUID}


<代码样式="保证金:0px;填充:1px 5px;边框:0像素;字体风格:继承;字体变:继承;字体重量:继承;行高:继承; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;字体大小:13像素;垂直对齐:基线;背景色:#eff0f1; white-space:pre-wrap"> DELETE
FROM Files WHERE ID = {GUID}


大多数工作都会在Select和Insert中进行。很少有更新和删除。

Most work will happen in Select and Insert. There will be very few updates and deletes.


谢谢。

推荐答案



您认为这是一种有效的方法吗?我在查看数亿条记录的插入/查询性能是什么?

Do you think this is a valid approach? What insert/query performance am I looking at with hundreds of millions of records?


嗨bobekhj,

这是否是一种有效的方法是否取决于您的详细要求和业务规则。根据当前信息,该方法可行。

Whether it is a valid approach or not depends on your detailed requirements and business rules. According to current information, the approach could work.

对于该表中的数百万条记录,您不必考虑太多性能。您可以根据SQL语句的执行计划处理性能问题。

For millions of records in that table, you don't have to consider too such about the performance. You could handle performance issue based on execution plan of SQL statements.

最好的问候,


这篇关于为大量行设计表。没有关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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