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

Default visibilty_column behavior is broken #68

Open
manfre opened this issue Aug 1, 2012 · 4 comments
Open

Default visibilty_column behavior is broken #68

manfre opened this issue Aug 1, 2012 · 4 comments

Comments

@manfre
Copy link

manfre commented Aug 1, 2012

From the docs:

If you want a performance boost, define visibility field on your model and add option visibility_column = 'your_field' on moderator class. Field must by a BooleanField. The manager that decides which model objects should be excluded when it were rejected, will first use this option to properly display (or hide) objects that are registered with moderation. Use this option if you can define visibility column in your model and want to boost performance. By default when accessing model objects that are under moderation, one extra query is executed per object in query set to determine if object should be excluded from query set. This method benefit those who do not want to add any fields to their Models. Default: None.

The default behavior of executing an additional query per object is severely broken. It forces the queryset to evaluate immediately, which results in an additional query for every record returned by the parent manager's default queryset. For most models, this is the entire table. This happens regardless of the filter, slicing, and whether or not the queryset is ever meant to be evaluated.

Example:

from django.db import connection

start_query_count = len(connection.queries)
qs = MyModel.objects.all().filter(pk=1)
assert start_query_count == len(connection.queries), 'No queries should have been executed'
@arowla
Copy link

arowla commented Aug 24, 2012

I was also interested in getting rid of the query-per-object behavior, as it was causing us severe performance problems, but I just confirmed that adding the visibility_column attribute to the DefaultModerator (or whatever your moderator class is called) indeed fixes the problem. In other words, with visibility_column properly set up, I was not able to reproduce this issue. Using django 1.4 and django-moderation 0.3.2.

@mgerring
Copy link

The visibility column option is nice, but the default behavior is still broken.

@grucha
Copy link

grucha commented Apr 26, 2021

Hey, is this library still maintained?
This issue should have been closed.

@DmytroLitvinov
Copy link
Collaborator

Hi @grucha ,
It is not under active development. If you found any issues, PRs are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants