Commit a96416a5 authored by Vincent Pelletier's avatar Vincent Pelletier

Always allow MySQL to use primary key.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22526 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b4d8826f
...@@ -2102,6 +2102,14 @@ class Catalog(Folder, ...@@ -2102,6 +2102,14 @@ class Catalog(Folder,
for table in index_from_table.keys(): for table in index_from_table.keys():
available_index_list = self.getIndex(table, index_from_table[table], key_list) available_index_list = self.getIndex(table, index_from_table[table], key_list)
if len(available_index_list) > 0: if len(available_index_list) > 0:
# Always give MySQL a chance to use PRIMARY key. It is much faster if
# current table is used in a join on primary key than forcing it to
# use another index.
# Note: due to a bug (?) in MySQL (at least 5.0.45 community), it is
# a syntax error to put "PRIMARY" keyword anywere besides at first
# position. Hence the "insert(0".
if 'PRIMARY' not in available_index_list:
available_index_list.insert(0, 'PRIMARY')
# tell mysql to use these index # tell mysql to use these index
table = from_table_dict.pop(related_table) table = from_table_dict.pop(related_table)
index_list_string = ', '.join(available_index_list) index_list_string = ', '.join(available_index_list)
......
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