On Thursday, March 31, 2016 at 6:46:10 PM UTC-4, Robert Smith wrote:
>
> 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.
>
I've been in your place.
1. It sounds like a great idea right now... but after few months "magic"
optimizations like this get in the way of your work.
2. The work required to make something like this function correctly is
really large.
3. The postgres planner is hard to deal with. depending on how you
configured the server, it might or might not use the hints you give it.
you don't need to use raw sql. if you want to, you can use bind parameters
to handle sql escaping.
if you want to stay in the orm...
i think you could translate this:
WHERE model.description % 'string' AND similarity(model.description,
'string') > 0.5`.
into something like this
session.query(Model)\
.filter(Model.description.op('%')(string),
func.similarity(Model.description, string) > 0.5
)
I used the `column.op()` syntax because it's useful for specifying certain
operators. I think the func should work like that, but I haven't used it
in a similar context in a long time.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.