Wow, again Rust and Golang frameworks perform very well. Note that using Actix with ORM objects is just as the same as using raw PHP and raw connections, something you would do… two decades ago?

哇,Rust和Golang框架再次表现出色。 请注意,将Actix与ORM对象一起使用与使用原始PHP和原始连接相同,您将在二十年前做些什么?

Let’s be honest. It’s very difficult to make 20 queries in a single request for a microservice. Unless there is a complex scenario, the one I did doesn’t go over 3 at best, including a single row insert when everything goes alright.

说实话。 在单个微服务请求中很难进行20个查询。 除非有复杂的场景,否则我最多不会超过3个场景,包括在一切正常的情况下插入一行。

Seems like Rust and Go should become my prefered choices. Rust is a more close-to-the-metal language, while Golang is aimed to microservices. I put both under my radar and started to dig what I could find. What you need to accomplish that top performance?

似乎Rust和Go应该成为我的首选。 Rust是一种更接近金属的语言,而Golang是针对微服务的。 我全神贯注,开始挖掘我能找到的东西。 您需要什么来达到最佳性能?

ORM方式或性能方式 The ORM way, or the performance way
JOIN
JOIN
Noting that the “ORM” column was full of raw connections to a PostgreSQL instance.
注意“ ORM”列充满了到PostgreSQL实例的原始连接。

The problem with going for raw SQL calls is that you become dependant on the database engine itself. There is no way to swap a DB engine, like going from SQLite to Microsoft SQL Server, in a transparent way. Most of ORM offer a way to add drivers for each RDBMS, so you can safely switch from one to another.

进行原始SQL调用的问题是您变得依赖于数据库引擎本身。 无法以透明方式交换数据库引擎,例如从SQLite切换到Microsoft SQL Server。 大多数ORM提供了一种为每个RDBMS添加驱动程序的方法,因此您可以安全地从一个切换到另一个。

I consider the Database Layer something apart from the Application, so these should be interchangeable anytime and keep the same behaviour. It makes our lives easier, and also allows both of them testable and easy to migrate if for some reason we need to change them. For example, you can test the application against SQLite before pushing a new revision that uses a real PostgreSQL database.

我认为数据库层应用程序有所不同,因此它们应随时可互换并保持相同的行为。 它使我们的生活更轻松,并且如果出于某种原因我们需要更改它们,则还允许它们可测试且易于迁移。 例如,您可以在推送使用真实PostgreSQL数据库的新修订之前,针对SQLite测试应用程序。

This is the part where ORM comes, and where most of the performance gains of any language are lost. ORMs are basically a layer between the framework and the database itself. One of the most easy ways to pick up are those who offer the ActiveRecord pattern: each record is an object that can be created, updated or deleted. This is one of the reasons why I choose Lumen/Laravel, since it’s brain dead easy to understand and quick to build from. When I need performance I can always instance a query builder to push a SQL statement to the database.

这是ORM出现的部分,而任何一种语言的大部分性能提升都将因此而丧失。 ORM基本上是框架和数据库本身之间的一层。 提供ActiveRecord模式的是最简单的方法之一:每个记录都是可以创建,更新或删除的对象。 这就是为什么我选择Lumen / Laravel的原因之一,因为它的大脑死了,易于理解并且可以快速构建。 当我需要性能时,我总是可以实例化查询构建器来将SQL语句推送到数据库。