最适合我的需求的数据库是什么?

发布于 2024-08-26 05:05:36 字数 563 浏览 2 评论 0原文

我目前正在使用 MS SQL Server 2008,但我不确定它是否是执行此特定任务的最佳系统。

我有一个像这样的表:

PK_ptA PK_ptB DateInserted LookupColA LookupColB ... LookupColF DataCol (ntext)

一个常见的查询是

SELECT TOP(1000000) DataCol FROM table 
WHERE LookupColA=x AND LookupColD=y AND LookupColE=z
ORDER BY DateInserted DESC 

该表大约有 10 亿行,每天插入 500 万行。

我对 SQL Server 的主要问题是分片或分散数据文件不太容易。此外,导出速度似乎达到每秒 1000 行(约 1MB/s),这看起来非常慢。

我遇到的另一个问题是,对于 SQL Server,如果我想添加新的 LookupCol,日志文件会急剧增长,需要大量很少使用的可用空间。

对于这个问题有明显更好的解决方案吗?

I am currently using MS SQL Server 2008 but I'm not sure it it is the best system for this particular task.

I have a single table like so:

PK_ptA PK_ptB DateInserted LookupColA LookupColB ... LookupColF DataCol (ntext)

A common query is

SELECT TOP(1000000) DataCol FROM table 
WHERE LookupColA=x AND LookupColD=y AND LookupColE=z
ORDER BY DateInserted DESC 

The table has about a billion rows with 5 million inserted per day.

My main problem with SQL Server is that it isn't too easy to shard or spread out the datafiles. Also, exporting seems to max out at 1000rows per second (about 1MB/s) which seems very slow.

Another problem I have is, with SQL Server, if I want to add a new LookupCol the log file grows enormously requiring a large amount of rarely used free space on tap.

Are there any obvious better solutions for this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空宴 2024-09-02 05:05:36

您遇到了问题,但问题不是 SQL Server。让我也忽略你似乎有一个糟糕的桌子设计。

  • 传播数据文件实际上非常容易。以后的重组并不那么容易,但也是可行的。您的表、文件组和文件布局如何?
  • 每秒导出 1mb 就是个笑话。严重地。我在几分钟内处理了 1.5 亿行文件 - 每分钟运行超过 60,000 行。有什么东西吓坏了。临时空间?你做过性能分析吗?硬件看起来怎么样?
  • 对于日志的使用没有任何作用。基本上像大多数专业数据库一样,日志包含事务期间所有更改的数据库页面。添加字段会更改 - 所有页面。

您应该:

  • 重新设计数据库(如果需要,请使用视图来保留相同的旧表),以便它不会有“LookupColA”等,而是标准化(LookupValue,以及由“column”编码的 LookuPTable) ”)。这样您就可以获得即时的附加字段。这变成了一个类似星型模式的数据仓库。
  • 进行性能分析。看起来你有一些问题。
  • 一定要告诉我们有关您的硬件的信息;)

这里的问题绝对不是 SQL Server,它与糟糕的表设计以及 - 可能 - 不足 - 硬件利用率不高有关。

You have a problem, and it is not SQL Server. let me also ignore that you seem to ahve a bad table design.

  • Spreading data files is actually pretty easy. REORGANIZING later is not that easy, but also doable. How is your table, filegroup and file layout?
  • export 1mb per second is a joke. Seriously. I have been handling 150 million row files in minutes - that runs down to a LOT more than 60.000 rows per minute. Something is freaking out. Temp space? Did you do a performance analysis? How does the hardware look?
  • Nothing will work for the log usage. Basically like most pro databases the log contains all changed database pages during a transaction. Adding a field changes - ALL pages.

You should:

  • Redesign the database (use a view to keep the same old table in place if you ahve to) so that it does not ahve "LookupColA" etc., but is normalized (LookupValue, and a LookuPTable that is coded by "column"). This way you get instant additional fields. This turns into a data warehouse like star schema.
  • Do a performance analysis. Looks like you ahve some problems.
  • Definitely tell us abou your hardware ;)

This problem here is definitely NOT SQL Server, it is related to bad table design AND - possibly - insufficient - badly utilized hardware.

千年*琉璃梦 2024-09-02 05:05:36

好的,表格设计(单独答案)。 Lokup 本质上是查找表。

所以....

  • LookupTable
  • pk (int)
  • TableType
  • Value
    作为字段

  • ValueTable

  • pk

  • ValueLookupMap table

  • ValueTable 条目的 ValueLookupMap 表 pk
  • 条目的 pk

所以,基本上,如果您添加一个查找“字段”那么您只需在 LookupTable 中创建一组条目,然后在 ValueLookupMap 中添加条目。

Ok, the table design (separate answer). Lokup are bassically lookup tables.

So....

  • LookupTable
  • pk (int)
  • TableType
  • Value
    as vields

  • ValueTable

  • pk

  • ValueLookupMap table

  • pk of ValueTable entry
  • pk of LookupTable entry

So, basically, if you add a lookup "field" then you just create a set of entries in the LookupTable then add entries in the ValueLookupMap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文