#107 ✓resolved

optimizations of any?

Reported by paulcc | July 28th, 2009 @ 08:30 AM

Is it worth optimising foo_equals_any [x,y,z] to "foo IN (x,y,z)"? or maybe to use regex | instead of "LIKE x OR LIKE y OR LIKE z" etc? just a thought

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson July 28th, 2009 @ 04:38 PM

    • State changed from “new” to “open”

    To be honest, I'm not 100% sure. I'm not familiar enough with the inner working of a database to know if there would be a performance difference. My guess would be no, since they are basically the same thing, but the query would look nicer. The reason I do this is because I basically loop through the method and set the condition. If you want to fork the repo and give it a try I think it would be a worth change. But i don't think its worth complicating the code. If you can figure out a way to cleanly do it then I'm all for it.

  • paulcc

    paulcc July 28th, 2009 @ 08:49 PM

    Quite possibly, it won't make much difference for the bigger db systems - I expect their optimizer to handle such rewrites.

    We'll be using this functionality a fair bit in Spree, so I'll keep an eye on performance issues and let you know if there's a difference.

  • Ben Johnson

    Ben Johnson July 30th, 2009 @ 02:42 AM

    • State changed from “open” to “resolved”

    Sure, I understand from a query / log perspective it doesn't look right. But the library perspective it is, it's really an issue of keeping my code DRY and simple. I'm basically just looping through a method and building the SQL, but if you find any performance issues with this please let me know and I will definitely optimize it. I just don't see that being the case, because in (X,X,X) and X or X or X are the exact same thing.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket