Commit 32405bd9 authored by Aurel's avatar Aurel

add a way to specify on which sort Catalog must tell mysql to use index

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13176 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a5e638b8
......@@ -641,6 +641,11 @@ class Catalog( Folder,
'type' : 'multiple selection',
'select_variable' : 'getColumnIds',
'mode' : 'w' },
{ 'id' : 'sql_catalog_index_on_order_keys',
'description' : 'Columns which should be used by specifying an index when sorting on them',
'type' : 'multiple selection',
'select_variable' : 'getSortColumnIds',
'mode' : 'w' },
{ 'id' : 'sql_catalog_topic_search_keys',
'description' : 'Columns which should be considered as topic index',
'type' : 'lines',
......@@ -686,6 +691,7 @@ class Catalog( Folder,
sql_search_result_keys = ()
sql_catalog_topic_search_keys = ()
sql_catalog_multivalue_keys = ()
sql_catalog_index_on_order_keys = ()
sql_catalog_related_keys = ()
sql_catalog_scriptable_keys = ()
......@@ -1058,6 +1064,20 @@ class Catalog( Folder,
keys.sort()
return keys
def getSortColumnIds(self):
"""
Calls the show column method and returns dictionnary of
Field Ids that can be used for a sort
"""
keys = {}
for table in self.getTableIds():
field_list = self._getCatalogSchema(table=table)
for field in field_list:
keys['%s.%s' % (table, field)] = 1
keys = keys.keys()
keys.sort()
return keys
def getTableIds(self):
"""
Calls the show table method and returns dictionnary of
......@@ -2078,6 +2098,12 @@ class Catalog( Folder,
related_table = from_table_dict.keys()[0]
table = from_table_dict[related_table]
# Check if it's a column for which we want to specify index
index_columns = getattr(self, 'sql_catalog_index_on_order_keys', [])
sort_column = '%s.%s' %(table, column)
if not sort_column in index_columns:
continue
# Group columns
if not index_from_table.has_key(table):
index_from_table[table] = [column,]
else:
......
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