From a8b5471d0258b87a3a2d002eb3b066c43edbf191 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Thu, 12 Sep 2013 12:48:29 -0400 Subject: [PATCH] Test Mike Rylander's patch for container join optimization Signed-off-by: Dan Scott --- .../lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index 431e26f38b..98f6c1df88 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -1094,12 +1094,13 @@ sub flatten { } $with .= " )"; - $from .= "\n" . ${spc} x 3 . "LEFT JOIN container_${filter_alias} ON container_${filter_alias}.record = m.source"; + my $optimize_join = 1 if $self->top_plan and !$NOT; + $from .= "\n" . ${spc} x 3 . ( $optimize_join ? 'INNER' : 'LEFT') . " JOIN container_${filter_alias} ON container_${filter_alias}.record = m.source"; - my $spcdepth = $self->plan_level + 5; - - $where .= $joiner if $where ne ''; - $where .= "${NOT}(container_${filter_alias} IS NOT NULL)"; + if (!$optimize_join) { + $where .= $joiner if $where ne ''; + $where .= "(container_${filter_alias} IS " . ( $NOT ? 'NULL)' : 'NOT NULL)'); + } } } } elsif ($filter->name eq 'record_list') { -- 2.11.0