Commit 31c063ea authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'upstream/master' into zope4py3

parents ddc6a2ab 9fa162e8
Pipeline #40083 failed with stage
in 0 seconds
erp5_advanced_ecommerce
erp5_ui_test_core
erp5_configurator_standard_categories
erp5_configurator_standard_trade_template
erp5_simulation_test
\ No newline at end of file
erp5_trade
erp5_base
erp5_configurator_standard_categories
\ No newline at end of file
erp5_base
\ No newline at end of file
......@@ -2,4 +2,5 @@ erp5_commerce_loyalty_program
erp5_simulation_test
erp5_configurator_standard_trade_template
erp5_configurator_standard_invoicing_template
erp5_configurator_standard_categories
erp5_simplified_invoicing
\ No newline at end of file
......@@ -426,9 +426,13 @@ CREATE TABLE %s (
0,
)[1]
else:
# MariaDB often choose processing_node_priority_date index
# but node2_priority_date is much faster if there exist
# many node < 0 non-groupable activities.
subquery = lambda *a, **k: str2bytes(bytes2str(b"("
b"SELECT 3*priority{} AS effective_priority, date"
b" FROM %s"
b" FORCE INDEX (node2_priority_date)"
b" WHERE"
b" {} AND"
b" processing_node=0 AND"
......@@ -781,9 +785,17 @@ CREATE TABLE %s (
0,
))
else:
if group_method_id:
force_index = ''
else:
# MariaDB often choose processing_node_priority_date index
# but node2_priority_date is much faster if there exist
# many node < 0 non-groupable activities.
force_index = b'FORCE INDEX (node2_priority_date)'
subquery = lambda *a, **k: str2bytes(bytes2str(b"("
b"SELECT *, 3*priority{} AS effective_priority"
b" FROM %s"
b" {}"
b" WHERE"
b" {} AND"
b" processing_node=0 AND"
......@@ -799,11 +811,11 @@ CREATE TABLE %s (
b" UNION ALL ".join(
chain(
(
subquery('-1', 'node = %i' % processing_node),
subquery('', 'node=0'),
subquery('-1', force_index, 'node = %i' % processing_node),
subquery('', force_index, 'node=0'),
),
(
subquery('-1', 'node = %i' % x)
subquery('-1', force_index, 'node = %i' % x)
for x in node_set
),
),
......@@ -821,7 +833,7 @@ CREATE TABLE %s (
# sorted set to filter negative node values.
# This is why this query is only executed when the previous one
# did not find anything.
result = Results(query(subquery('+1', 'node>0'), 0))
result = Results(query(subquery('+1', force_index, 'node>0'), 0))
if result:
# Reserve messages.
uid_list = [x.uid for x in result]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment