[Erp5-report] r22526 - /erp5/trunk/products/ZSQLCatalog/SQLCatalog.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jul 17 16:32:24 CEST 2008


Author: vincent
Date: Thu Jul 17 16:32:24 2008
New Revision: 22526

URL: http://svn.erp5.org?rev=22526&view=rev
Log:
Always allow MySQL to use primary key.

Modified:
    erp5/trunk/products/ZSQLCatalog/SQLCatalog.py

Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=22526&r1=22525&r2=22526&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py Thu Jul 17 16:32:24 2008
@@ -2102,6 +2102,14 @@
       for table in index_from_table.keys():
         available_index_list = self.getIndex(table, index_from_table[table], key_list)
         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
           table = from_table_dict.pop(related_table)
           index_list_string = ', '.join(available_index_list)




More information about the Erp5-report mailing list