简体   繁体   English

Azure PostgreSql 性能不好

[英]The performance of Azure PostgreSql is bad

I am using Azure PostgreSQL, in my web project, I save files(such as images,.csv) in table as bytea data type.我正在使用 Azure PostgreSQL,在我的 web 项目中,我将文件(如图像,.csv)保存为 bytea 数据类型。

Now I can get files from Azure PostgreSQL successfully, but the performance is not so good.现在我可以成功地从 Azure PostgreSQL 获取文件,但性能不太好。 it will take more than 20s to retrieve files if I request for multiple files, even sometimes I got timeout error from my web server.如果我请求多个文件,检索文件需要20s秒,即使有时我的 web 服务器出现timeout error So is there anyone could give me some advice to solve this?那么有没有人可以给我一些建议来解决这个问题? Any suggestion is appreciated.任何建议表示赞赏。

As @eshirvana said, saving files in databases is not a good idea.正如@eshirvana 所说,将文件保存在数据库中并不是一个好主意。 As we know,the performance that querying blobs or files in SQL is awful and it also greatly cost DB server memory.众所周知,查询 SQL 中的 blob 或文件的性能非常糟糕,并且还大大消耗了 DB 服务器 memory。 Saving URLs in DB only is recommended.建议仅将 URL 保存在数据库中。

If you are using Azure Cloud, you can save your files in Azure blob storage .如果您使用的是 Azure Cloud,您可以将文件保存在Azure blob storage中。 And you can save your file storage blob URL in your DB table.您可以将文件存储 blob URL 保存在数据库表中。

Your client could get the file URL from the webserver by SQL query and access files in Azure storage by the file URL. Your client could get the file URL from the webserver by SQL query and access files in Azure storage by the file URL. This way could ease the IO and memory pressure of your web server and greatly improve the query performance.这样可以缓解web服务器的IO和memory压力,大大提高查询性能。

What's more, creating your SQL service in the region that you are in or near could also reduce network latency.此外,在您所在或附近的区域创建 SQL 服务还可以减少网络延迟。 You can see all the Azure datacenter regions here .您可以在此处查看所有 Azure 数据中心区域

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

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