On Fri, Aug 7, 2015 at 12:05 PM, kk <krm...@gmail.com> wrote:
> On Friday 07 August 2015 03:03 PM, Ladislav Lenart wrote:
>>
>> Hello.
>>
>> ORM is certainly slower. How much depends A LOT on your workload. For
>> example
>> bulk operations with ORM are an order of magnitude slower than raw SQL. On
>> the
>> other hand, SQLAlchemy Core let's you write generative SQL queries without
>> ORM
>> features which are as performant as raw SQL.
>
>
> So is is there some kind of a method to have some prepared sql statements in
> SQLAlchemy itself?
> I have seen that prepared statements in other languages like Java do a great
> job.

Depending on the dialect and driver, you can use executemany.
Not all drivers implement executemany with prepared statements though,
check your case.

>> Overall SQLAlchemy is an excellent
>> library to work with!
>
>
> So you mean performance will really get hit when pure ORM is used.
> So shold I use a mixture?
> For inserts let's say orm and for bulk select queries some prepared
> statement like thing (if it exists )?

It really depends on each use case.

If your concern is whether ORM queries will be efficient, don't worry,
SQLAlchemy is powerful enough that you can make almost any kind of
query with the ORM. Almost all the optimizations you could do to plain
SQL are doable at the ORM level.

If your concern is CPU overhead on the application side, yes, the ORM
does induce quite an overhead, but whether it's a problem or not
greatly depends on your use case, the number of objects your
transactions will be handling, the complexity of the mapping, your
latency and thoughput constraints, etc. I've convinced myself over
time that a little overhead is fine in exchange for the benefits the
ORM gives you, in ease of coding mostly, but also robustness (the ORM
solves some issues that are hard to handle correctly and robustly with
raw SQL), and SQLAlchemy is flexible enough that you can usually
escape to raw sql if/when you need to. You shouldn't optimize
prematurely, the ORM won't be a death trap as it happens with other
ORMs.

So, we're saying we need more information if we're to give a meaningful answer.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to