While I'm still not entirely sure exactly what you're doing (some examples would help), I can't help but think that your 'linked_tables' and 'unlinked_tables' would be better off as hashes so that you wouldn't have to iterate through them quite so often:
Anonymous block for scoping { my( %linked_tables, %unlinked_tables); #------------------------------------------ sub _get_table_relations { my( $self,$tables,$conditions ) = @_; #prep lists @unlinked_tables{keys %$tables} = undef; %linked_tables = (); my @tables_nolinks = (); #no relations to be found if there's only one table { no warnings; return if scalar( %unlinked_tables ) <= 1; } # try to find a link for each of the supplied tables for my $table ( keys %unlinked_tables ) { next if exists $linked_tables{$table}; push @tables_nolinks, $table unless $self->_table_relation_helper($table,$conditions); } csWarn(class=>csErrorClass('CODE_PARAMS'), severity=>csErrorScale('MODERATE'), message=>'Could not find relations '. 'certain tables in this view.', debug=>"tables without relations:". join(',',@tables_nolinks) ) if scalar( @tables_nolinks ); return 1; } #--------------------------------------------- sub _table_relation_helper { my ($self,$table,$conditions) = @_; foreach my $table2 (keys %linked_tables, keys %unlinked_tables) { # a link exists if( exists $self->{_links}{$table,$table2} ) { #store the conditions of our found relationship with #our other conditions push @{ $conditions->{axioms} }, ( $self->{_links}{$table,$table2}{op} eq $conditions->{op} and ( $conditions->{op} eq 'and' or $conditions->{op} eq 'or' ) ) ? @{ $self->{_links}{$table,$table2}{axioms} } : { %{ $self->{_links}{$table,$table2} } }; #first check to see if $table2 needs linking if (exists $unlinked_tables{$table2}) { delete $unlinked_tables{$table2}; $self->_table_relation_helper($table2,$conditions) unless $table2 =~ /\s/; } #then add $table to $linked_tables $linked_tables{$table} = undef; return 1; #short circuit } } return 0; } }

In reply to Re: Efficiency in Mapping Relationships by runrig
in thread Efficiency in Mapping Relationships by AidanLee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.