[sqlalchemy] Re: `func.similarity` performance

2016-04-01 Thread Robert Smith
Jonathan and Sergey: I tried to use the `op()` method but for some reason it fails in this particular query (session.query(Model).filter(Model.description.op('%')('string'))). I get the following error: /home/user/anaconda/envs/gensim/lib/python3.5/site-packages/sqlalchemy/engine/default.py

Re: [sqlalchemy] `func.similarity` performance

2016-04-01 Thread Robert Smith
is not trivial, it is better to look for alternatives. On Thursday, March 31, 2016 at 6:15:41 PM UTC-6, Mike Bayer wrote: > > > > On 03/31/2016 06:40 PM, Robert Smith wrote: > > Mike Bayer: > > > > Thank you for your response. I wasn't really asking whether the >

Re: [sqlalchemy] `func.similarity` performance

2016-03-31 Thread Robert Smith
Jonathan Vanasco: Thank you. That's a good idea but in this case, I'm really wondering if sqlalchemy should use that small change to improve performance quite a bit in this type of queries. Otherwise, I think I would need to rely on raw SQL to perform a similarity operation and I'm not sure if

Re: [sqlalchemy] `func.similarity` performance

2016-03-31 Thread Robert Smith
erstand what you mean. Can you describe this a bit more? Regards On Thursday, March 31, 2016 at 7:43:11 AM UTC-6, Mike Bayer wrote: > > > > On 03/30/2016 09:50 PM, Robert Smith wrote: > > I'm using sqlalchemy 1.0.12 with postgreSQL 9.4.6 with the pg_trgm > > extensio

[sqlalchemy] `func.similarity` performance

2016-03-30 Thread Robert Smith
I'm using sqlalchemy 1.0.12 with postgreSQL 9.4.6 with the pg_trgm extension enabled. Basically, I'm performing a similarity-based query on a single column: In [26]: str(session.query(Model).order_by(desc(func.similarity(Model.description, 'string'))).limit(100)) Out[26]: 'SELECT model.id AS