python - Creating Index After the Fact SQLAlchemy -


i have sql database querying using sqlalchemy. when filter query numeric column returns result quickly. example:

result = session.query(myobject).filter(myobject.myinteger == 1).all() 

note not primary id class, 1 variable of many. however, when try filter query column consists of 10 character string, takes @ least order of magnitude longer return query. example, query this:

result = session.query(myobject).filter(myobject.mystring == 'q1213w3239').all() 

one option speed process index mystring column. unsure, however, how interacts sqlalchemy. believe if create index of mystring in database, using webmin (which use administer database), database automatically use index queries filter on variable. correct or have somehow let either sqlalchemy know index or tell database via sqlalchemy use index?

if create index in database, using webmin or tool, sqlalchemy automatically find it.

it might not automatically use it, nor if index used, might not faster. depends on several factors.

see also: http://www.sitepoint.com/using-explain-to-write-better-mysql-queries/


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -