The little diddly below is comparing performance of orm access vs sql expression language.

When I run it with number=1 I get a 5.8x advantage for sql. When I run it 10 times I get a 2.7x advantage. The actual numbers are, respectively:

1.47375132
0.25630808

5.45569524
1.96911144

Is this a typical/expected difference in performance between the two query 
methods?

Michael



def timing1():
    """orm method"""
    recs = sess.query(dm.Dealer).order_by('name').all()

def timing2():
    """sql method"""
    dealers = dm.Dealer.__table__
    recs = engine.execute(select([dealers], order_by='name')).fetchall()

def timing():
    t = timeit.Timer(timing1)
    print t.timeit(number=1)
    t = timeit.Timer(timing2)
    print t.timeit(number=1)

if __name__ == "__main__":
    db.start(DATABASE)
    from common.database import engine
    sess = db.Session()
    timing()

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to