kapilratnani / django_hana

[Discontinued] Django db backend for SAP HANA
BSD 3-Clause "New" or "Revised" License
20 stars 13 forks source link

Call `create_or_set_default_schema` only once per connection #20

Closed lanzz closed 10 years ago

lanzz commented 10 years ago

create_or_set_default_schema is being called once for every new cursor, which results in performing at least a select (1) as a from schemas ... query for every cursor. This practically doubles the number of queries performed, as very often cursors are only used for a single query, and there might be cases where a cursor is instantiated but never used, which will still perform the schema check query.

Moved the create_or_set_default_schema call into the connect method, so that it is called only once per connection instead of once per cursor.

kapilratnani commented 10 years ago

Cool! i had thought about doing it from a long time. Procrastination!. Thanks for doing it for me.