关系型数据库管理系统(RDBMS)对Golang的影响

huangapple go评论90阅读模式
英文:

RDBMS impact on Golang

问题

我不打算在这个问题上进行冗长的描述,关于我所测试和计算的内容。我更感兴趣的是实际的最新实践表现。

我已经阅读了很多文章,其中一些非常怀疑或者非常支持某个库。我目前正在测试gorp,但我不知道如何将这样的库与其他库的性能进行比较。

我知道gorp是一个额外的层,试图将ORM添加到基本的SQL驱动程序/实现中,但是看到Go的代码非常清晰,并且它在执行的每个方面都非常接近底层。这不像我习惯的PHP/Python/JAVA,你必须在无尽的复杂层次中导航,才能真正看到一个包在本质上做了什么。

所以我的问题是,是否有人可以分享(基准测试总是受欢迎的 :))他们在这个领域的经验和知识。

我不认为NoSQL类型的解决方案适用于我的项目。我所有的项目都严重依赖于业务逻辑和相互关系。我还想知道Postgres是否胜过MySQL。在使用Django(Python)时,我注意到使用Postgres可以显著提高性能,但我从未找到证据证明这是由于Postgres核心实现还是Django使用包装器的方式。

小更新

重新阅读问题后,我注意到我有点错过了实际目标。实际上,我正在寻找最适合的SQL解决方案,以最小程度地减慢Golang本身的速度。我知道SQL可以并发运行,但是在作为Web服务运行时,也要考虑到高流量的情况。如果这样可以显著提高性能,我也不介意再次放弃ORM部分。

英文:

I'm not going to make a big long rattle on this question about what I've tested and number crunching. I'm more interested in actual up-to-date practice performances.

I've read tons of articles already and some of them are pretty skeptical or either very pro to one library. I'm currently testing a bit with gorp, yet I have no clue how to compare the performances of such a library towards others.

I know gorp is an extra layer that tries to add ORM to the basic SQL driver/implementation, but seeing Go's extremely clear code and being it very close to the bone on everything it does. It's not like with PHP/Python/JAVA what I'm used too, where you have to navigate through endless layers of complexity to actually see what a package does in its essence.

So my question is if anyone can share (benchmarks are always welcome 关系型数据库管理系统(RDBMS)对Golang的影响 ) their experience and knowledge on this subject.

I don't think a NoSQL-type solution is an option for my projects. All my projects always strongly depend on business logic and intertwined relationships. I also wonder if Postgres will be a win over MySQL. With Django (Python) I noticed significant performance gain using Postgres, but I never found prove on that matter if it was due to the Postgres core implementation or just Django's way of using the wrapper.

Small update

After rereading the question I noticed I kind of missed the actual goal of it. I'm actually looking for the most suitable SQL solution that will least slow down Golang itself. I know the SQL runs concurrent, but also concerning heavy traffic when running it as a web service. I won't be really bothered to drop the ORM part again if that will get me major gain on performance.

答案1

得分: 6

如果你需要使用ORM,sqlxgorp是不错的Go选项。就个人而言,我有点守旧,我更愿意为给定的类型Foo编写一个实现FooDS接口的FooDB结构体。你的应用程序中的所有内容都使用FooDS。 (DB = 数据库,DS = 数据存储)

你的FooDB实现可以使用任意数量的底层技术,如MongoDB、LevelDB、SQL等,它可以随着应用程序的变化而变化,而这种变化对于应用程序的其余部分是透明的(因为其余部分使用FooDS)。

我会默认使用database/sql(预编译语句等),而最成熟的Go SQL驱动程序是Julien Schmidt的MySQL驱动程序:https://github.com/go-sql-driver/mysql

英文:

If you need to use an ORM sqlx or gorp are good Go options. Personally, I am a bit old school and I would rather for a given type Foo, I would rather write a FooDB struct that implements a FooDS interface. Everything in your app just uses FooDS. (DB = database, DS = datastore)

Your FooDB implementation could be using any number of underlying technologies MongoDB, LevelDB, SQL, etc and it can change as your app changes and this change is transparent to the rest of your app (since the rest of your app uses FooDS).

I would default to using database/sql (Prepared statements, etc) and the most mature Go SQL driver is Julien Schmidt's MySQL driver: https://github.com/go-sql-driver/mysql

huangapple
  • 本文由 发表于 2014年2月8日 22:25:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/21647192.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定