Entity.get() should issue 'limit 2' #83

Closed
socketpair opened this Issue Oct 13, 2014 · 2 comments

Projects

None yet

2 participants

@socketpair

One of the purposes of entity.get() is to detect MultipleObjectsFoundError. If you add limit 2 to SQL queries, SQL server can use less resources while executing the query. For example, SQL server can stop populating internal cache if only two records needed. Yes I know that we may use cursors, but still sure that limit 2 will not hurt in performance in any way.

@kozlovsky kozlovsky self-assigned this Oct 13, 2014
@kozlovsky
Contributor

Agreed, should be fixed

@kozlovsky kozlovsky closed this in 564a706 Oct 28, 2014
@kozlovsky
Contributor

Now Pony adds LIMIT 2 when it thinks that a query can return more than one row. But when Pony sees that the query uses an unique key and thus no duplicates are possible, then LIMIT 2 will not be added, because it looks redundant and shouldn't influence anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment