简体   繁体   English

sql 服务器分区表在大表中没有性能?

[英]sql server partition table not performance in big tables?

I have table with 35 millions rows.我有 3500 万行的表。 When I select rows as shown as that was not working and It takes a long time and eventually gives a memory error (my ram is 32GB).当我 select 行如图所示不起作用并且需要很长时间并最终给出 memory 错误(我的内存为 32GB)时。

I partitioned the table based on the monthly date and I have 64 table as shown as我根据每月日期对表进行了分区,我有 64 个表,如图所示表分区

But query not working again and It takes a long time and eventually gives a memory error.但是查询不再起作用,并且需要很长时间并最终给出 memory 错误。 How can I do solve this problem?我该如何解决这个问题?

This is basically your query:这基本上是您的查询:

select s.*
from student s
where s.id = (select max(si.id)
              from studentIndex si
              where si.family = s.name and si.name_ship = s.name_ship
             )    and 
      try_convert(numeric(38, 12), s.Length ) between 18.485411 and 23.51031 and
      try_convert(numeric(38, 12), s.Weight ) between 21.77079 and 77.13644 and
      s.time > 1594326600;

This is basically a full table scan, so I don't see why it would run out of member.这基本上是一个全表扫描,所以我不明白为什么它会用完成员。 The exception is the correlated subquery.例外是相关子查询。 For that, you need an index on studentIndex(family, name_ship) -- and to be sure that the columns are of the same time (otherwise, the index may not be used).为此,您需要一个关于studentIndex(family, name_ship)的索引——并确保这些列是同一时间的(否则,可能不会使用该索引)。

Your length and width comparisons look an awful lot like geographic coordinates.您的lengthwidth比较看起来非常像地理坐标。 I might also suggest a GIS solution.我可能还会建议一个 GIS 解决方案。 However, if those are latitudes and longitudes, the area is pretty big, so GIS might not really be that helpful.但是,如果这些是纬度和经度,则该区域非常大,因此 GIS 可能并没有那么有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM