查询太大而无法放入内存
本主题讨论仓库所有者或管理员如何解决内存溢出,从而提高查询性能。
如果仓库在执行查询时内存不足,性能会急剧下降,因为内存字节必须“溢出”到本地磁盘存储上。如果查询需要更多内存,则会溢出到远程云提供商的存储上,造成性能进一步恶化。
Note
You must have access to the shared SNOWFLAKE database to execute the diagnostic queries provided in this topic. By default, only the ACCOUNTADMIN role has the privileges needed to execute the queries.
寻找溢出到存储的查询
此查询根据溢出到本地和远程存储的字节数,确定严重程度排名前 10 位的违规查询。
建议
数据溢出到存储时,可能会对查询性能产生负面影响(尤其是当查询必须溢出到远程存储时)。为了缓解这种情况,Snowflake 建议:
- 使用更大的仓库(有效地增加操作的可用内存/本地存储空间)
- 以较小的批次处理数据。
You can use the Query Profile to identify which operation nodes are causing data to spill to storage. For considerations for selecting the appropriate warehouse sizing, please refer to Warehouse considerations.
For more information about the performance implications of spilling, see the community article Performance impact from local and remote disk spilling (https://community.snowflake.com/s/article/Performance-impact-from-local-and-remote-disk-spilling).
Tip
When the query acceleration service (QAS) is enabled, Snowflake writes a small amount of data to remote storage
for each eligible query, even if QAS isn’t used for that query. Therefore, don’t be concerned by a nonzero
value for bytes_spilled_to_remote_storage in the QUERY_HISTORY view when QAS is enabled.