Skip to content

Commit 1afce42

Browse files
committed
Increase performance on find_existing_attribute_option_group query
When trying to create alot of options this is really slow
1 parent f24ef46 commit 1afce42

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

oscarapi/utils/exists.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ def find_existing_attribute_option_group(name, options):
5757
AttributeOptionGroup.objects.filter(name=name)
5858
.annotate(options_count=models.Count("options"))
5959
.filter(options_count=len(options))
60+
.filter(options__option__in=option)
6061
)
61-
for option in options:
62-
query = query.filter(options__option=option)
6362

6463
try:
6564
return query.get()

0 commit comments

Comments
 (0)