Question

I have a Drupal 6 application that requires more joins than that 61 table join mySQL limit allows. I understand that this is an excessive number, but it is ran only once a day, and the results are cached for further reference.

Are there any mySQL configuration parameters that could be of help, or any other approaches short of changing the logic behind collecting the data?

No correct solution

OTHER TIPS

My approach would be to split the humongous query into smaller, simpler queries, and use temporary tables to store the intermediate steps. I use this approach frequently and it helps me a lot (sometimes it is even faster to create some temp tables than to join all the tables in one big query).

Something like this:

drop table if exists temp_step01;
create temporary table temp_step01
    select t1.*, t2.someField
    from table1 as t1 inner join table2 as t2 on t1.id = t2.table1_id;
-- Add the appropriate indexes to optimize the subsequent queries
alter table temp_step01
    add index idx_1 (field1);
-- Create all the temp tables that you need, and finally show the results
select sXX.*
from temp_stepXX as sXX;

Remember: Temporary tables are visible only to the connection that creates them. If you need to make the result visible to other connections, you'll need to create a "real" table (of course, that is only worth with the last step of your process).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top