Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5
Commits
5b96a405
Commit
5b96a405
authored
Mar 10, 2022
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMFActivity.Activity.SQLBase: Limit the number of subqueries per dependency lookup query.
parent
c629ee70
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
16 deletions
+30
-16
product/CMFActivity/Activity/SQLBase.py
product/CMFActivity/Activity/SQLBase.py
+30
-16
No files found.
product/CMFActivity/Activity/SQLBase.py
View file @
5b96a405
...
@@ -68,6 +68,12 @@ UID_SAFE_BITSIZE = 63
...
@@ -68,6 +68,12 @@ UID_SAFE_BITSIZE = 63
# enough while yielding one order of magnitude collision probability
# enough while yielding one order of magnitude collision probability
# improvement.
# improvement.
UID_ALLOCATION_TRY_COUNT
=
10
UID_ALLOCATION_TRY_COUNT
=
10
# Limit the number of UNION-joined subqueries per query when looking for
# blocking activities. Used to take a slice from a list.
# XXX: 5000 is known to work on a case on "after_tag" dependency, which fails
# at 5400 with:
# ProgrammingError: (1064, "memory exhausted near [...]")
_MAX_DEPENDENCY_UNION_SUBQUERY_COUNT
=
-
5000
def
sort_message_key
(
message
):
def
sort_message_key
(
message
):
# same sort key as in SQLBase.getMessageList
# same sort key as in SQLBase.getMessageList
...
@@ -592,12 +598,19 @@ CREATE TABLE %s (
...
@@ -592,12 +598,19 @@ CREATE TABLE %s (
base_sql_prefix
=
'(SELECT %s FROM '
%
(
base_sql_prefix
=
'(SELECT %s FROM '
%
(
','
.
join
(
column_list
),
','
.
join
(
column_list
),
)
)
for
row
in
db
.
query
(
subquery_list
=
[
' UNION '
.
join
(
base_sql_prefix
+
table_name
+
sql_suffix
base_sql_prefix
+
table_name
+
sql_suffix
for
table_name
in
table_name_list
for
table_name
in
table_name_list
for
sql_suffix
in
sql_suffix_list
for
sql_suffix
in
sql_suffix_list
),
]
while
subquery_list
:
# Join queries with a UNION, to reduce per-query latency.
# Also, limit the number of subqueries per query, as their number can
# largely exceed the number of activities being considered multiplied
# by the number of activty tables: it is also proportional to the
# number of distinct values being looked for in the current column.
for
row
in
db
.
query
(
' UNION '
.
join
(
subquery_list
[
_MAX_DEPENDENCY_UNION_SUBQUERY_COUNT
:]),
max_rows
=
0
,
max_rows
=
0
,
)[
1
]:
)[
1
]:
# Each row is a value which blocks some activities.
# Each row is a value which blocks some activities.
...
@@ -608,6 +621,7 @@ CREATE TABLE %s (
...
@@ -608,6 +621,7 @@ CREATE TABLE %s (
# ...but update result immediately, in case there is no next
# ...but update result immediately, in case there is no next
# outermost iteration.
# outermost iteration.
result
.
difference_update
(
dependent_message_set
)
result
.
difference_update
(
dependent_message_set
)
del
subquery_list
[
_MAX_DEPENDENCY_UNION_SUBQUERY_COUNT
:]
dependency_value_dict
.
clear
()
dependency_value_dict
.
clear
()
return
result
return
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment