Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

socketpair opened this issue Oct 13, 2014 · 2 comments
Assignees

Comments

@socketpair
Copy link

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
Copy link
Member

Agreed, should be fixed

@kozlovsky
Copy link
Member

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
Projects
None yet
Development

No branches or pull requests

2 participants