[openstack-dev] [Glance] Replacing Glance DB code to Oslo DB code.

Joshua Harlow harlowja at yahoo-inc.com
Mon Aug 19 04:56:56 UTC 2013


Another good article from an ex-coworker that keeps on making more and more sense the more projects I get into...

http://seldo.com/weblog/2011/08/11/orm_is_an_antipattern

Your mileage/opinion though may vary :)

Sent from my really tiny device...

On Aug 18, 2013, at 8:12 PM, "Robert Collins" <robertc at robertcollins.net<mailto:robertc at robertcollins.net>> wrote:

On 19 August 2013 14:22, Jay Pipes <jaypipes at gmail.com<mailto:jaypipes at gmail.com>> wrote:

I'm completely with Joshua here - the ORM layer is more often than not
a source of bugs and performance issues.


If used improperly, yep.

http://www.codinghorror.com/blog/2006/06/object-relational-mapping-is-the-vietnam-of-computer-science.html

There is no proper use of an ORM.


We don't use the SQLAlchemy ORM for cross-SQL-DB support - thats a
lower layer. It's the model objects themselves that we use the ORM
for, and we could use SQLAlchemy's lower layers but not the ORM.


Hmmm, not quite... see below.



An alternative I think would be better would be to scrap the use of
the SQLAlchemy ORM; keep using the DB engine abstraction support.


Just keep in mind that the Session and Query objects and their related APIs
are in the SQLAlchemy ORM, not the SQLAlchemy Core.

Ok, so either it's not a bright line, or we'd need to have an
alternative thing - not just a reimplementation either, cause that's
pointless.

But sure, ok.

But then I guarantee somebody is gonna spend a bunch of time writing an
object-oriented API to the model objects because the ORM is very useful for
the data modification part of the DB interaction.

!cite - seriously...

Because people will complain about having to do this:

conn = engine.connection()
# instances is the sqlalchemy Table object for instances
inst_ins = instances.insert().values(blah=blah)
ip_ins = fixed_ips.insert().values(blah=blah)
conn.execute(ip_ins)
conn.execute(inst_ins)
conn.close()

This strawman is one way that it might be written. Given that a
growing set of our projects have non-SQL backends, this doesn't look
like the obvious way to phrase it to me.

instead of this:

i = Instance(blah=blah)
ip = FixedIp(blah=blah)
i.fixed_ips.append(ip)
session.add(u)
session.commit()

And so you've thrown the baby out with the bathwater and made more work for
everyone.

Perhaps; or perhaps we've avoided a raft of death-by-thousand-cuts
bugs across the project.

-Rob

--
Robert Collins <rbtcollins at hp.com<mailto:rbtcollins at hp.com>>
Distinguished Technologist
HP Converged Cloud

_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130819/881db185/attachment.html>


More information about the OpenStack-dev mailing list