uselist=False doesn't LIMIT 1

Issue #1196 resolved
Former user created an issue

on Mapper() i have relation() i use primaryjoin, and uselist=False, but i also want to have LIMIT=1 on my join it would be much faster!! SA should add the limit itself when uselist=False

since I set up uselist=False it is obvious that JOIN should be limited to 1, this wil bring a performance boost!

Comments (6)

  1. Former user Account Deleted

    ok, but even if it is for One-to-One , LIMIT 1 will make it work faster for some DB and adding limit=X feature IMHO will be a benefit.

  2. Former user Account Deleted
    • removed status
    • changed status to open

    I was browsing the relation() code and i think that there will not be much efford tplace an aditional parameter "limit" to it will it? aditionaly I think, that uselist tells that there will be only 1 object related. AFAIK LIMIT here will be helpfull and it will reduce the query time. i think that or uselist false and default limit 1 or aditional limit parameter should be considered.

  3. Mike Bayer repo owner

    LIMIT is not supported by every database and for a DB like oracle, will add significant overhead as well as reduce stability since Oracle has to produce a nested subquery in order to simulate LIMIT. I'm also skeptical that placing a LIMIT on a result set that is only one row in the first place has any positive effect, do you have any source to back this up ?

  4. Michael Trier

    I'm closing this. I can't see any reason why a limit 1 would make sense here. If you can show performance tests that indicate it makes a difference we can consider it but I doubt that's the case. Also as zzzeek said LIMIT is not supported everywhere, which complicates things.

  5. Log in to comment