[Bast-commits] r8342 - in DBIx-Class/0.08/branches/prefetch_pager:
lib/DBIx/Class/Storage t/count t/prefetch t/search
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sun Jan 17 15:29:21 GMT 2010
Author: ribasushi
Date: 2010-01-17 15:29:20 +0000 (Sun, 17 Jan 2010)
New Revision: 8342
Modified:
DBIx-Class/0.08/branches/prefetch_pager/lib/DBIx/Class/Storage/DBIHacks.pm
DBIx-Class/0.08/branches/prefetch_pager/t/count/prefetch.t
DBIx-Class/0.08/branches/prefetch_pager/t/prefetch/grouped.t
DBIx-Class/0.08/branches/prefetch_pager/t/search/related_strip_prefetch.t
Log:
This is made out of awesome
Modified: DBIx-Class/0.08/branches/prefetch_pager/lib/DBIx/Class/Storage/DBIHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/prefetch_pager/lib/DBIx/Class/Storage/DBIHacks.pm 2010-01-17 15:01:02 UTC (rev 8341)
+++ DBIx-Class/0.08/branches/prefetch_pager/lib/DBIx/Class/Storage/DBIHacks.pm 2010-01-17 15:29:20 UTC (rev 8342)
@@ -17,24 +17,30 @@
#
# This code will remove non-selecting/non-restricting joins from
-# {from} specs, aiding the RDBMS query optimizer.
+# {from} specs, aiding the RDBMS query optimizer
#
sub _prune_unused_joins {
- my $self = shift;
+ my ($self) = shift;
- my $from = shift;
+ my ($from, $select, $where, $attrs) = @_;
+
if (ref $from ne 'ARRAY' || ref $from->[0] ne 'HASH' || ref $from->[1] ne 'ARRAY') {
return $from; # only standard {from} specs are supported
}
- my $aliastypes = $self->_resolve_aliastypes_from_select_args($from, @_);
+ my $aliastypes = $self->_resolve_aliastypes_from_select_args(@_);
+ # a grouped set will not be affected by amount of rows. Thus any
+ # {multiplying} joins can go
+ delete $aliastypes->{multiplying} if $attrs->{group_by};
+
+
my @newfrom = $from->[0]; # FROM head is always present
my %need_joins = (map { %{$_||{}} } (values %$aliastypes) );
for my $j (@{$from}[1..$#$from]) {
push @newfrom, $j if (
- ! $j->[0]{-alias} # legacy crap
+ (! $j->[0]{-alias}) # legacy crap
||
$need_joins{$j->[0]{-alias}}
);
Modified: DBIx-Class/0.08/branches/prefetch_pager/t/count/prefetch.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch_pager/t/count/prefetch.t 2010-01-17 15:01:02 UTC (rev 8341)
+++ DBIx-Class/0.08/branches/prefetch_pager/t/count/prefetch.t 2010-01-17 15:29:20 UTC (rev 8342)
@@ -55,12 +55,13 @@
SELECT genre.genreid
FROM (
SELECT me.artistid, me.name, me.rank, me.charfield
- FROM artist me GROUP BY me.artistid, me.name, me.rank, me.charfield
+ FROM artist me
+ GROUP BY me.artistid, me.name, me.rank, me.charfield
) me
JOIN cd cds ON cds.artist = me.artistid
JOIN genre genre ON genre.genreid = cds.genreid
- LEFT JOIN cd cds_2 ON cds_2.genreid = genre.genreid
- WHERE ( genre.name = ? ) GROUP BY genre.genreid
+ WHERE ( genre.name = ? )
+ GROUP BY genre.genreid
)
count_subq
)',
Modified: DBIx-Class/0.08/branches/prefetch_pager/t/prefetch/grouped.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch_pager/t/prefetch/grouped.t 2010-01-17 15:01:02 UTC (rev 8341)
+++ DBIx-Class/0.08/branches/prefetch_pager/t/prefetch/grouped.t 2010-01-17 15:29:20 UTC (rev 8342)
@@ -148,7 +148,6 @@
FROM (
SELECT me.cdid
FROM cd me
- LEFT JOIN track tracks ON tracks.cd = me.cdid
WHERE ( me.cdid IS NOT NULL )
GROUP BY me.cdid
LIMIT 2
Modified: DBIx-Class/0.08/branches/prefetch_pager/t/search/related_strip_prefetch.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch_pager/t/search/related_strip_prefetch.t 2010-01-17 15:01:02 UTC (rev 8341)
+++ DBIx-Class/0.08/branches/prefetch_pager/t/search/related_strip_prefetch.t 2010-01-17 15:29:20 UTC (rev 8342)
@@ -25,12 +25,11 @@
SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
FROM cd me
JOIN artist artist ON artist.artistid = me.artist
- LEFT JOIN track tracks ON tracks.cd = me.cdid
+ LEFT JOIN track tracks ON tracks.cd = me.cdid
WHERE ( tracks.id != ? )
LIMIT 2
) me
JOIN artist artist ON artist.artistid = me.artist
- LEFT JOIN track tracks ON tracks.cd = me.cdid
JOIN tags tags ON tags.cd = me.cdid
WHERE ( tags.tag IS NOT NULL )
GROUP BY tags.tagid, tags.cd, tags.tag
More information about the Bast-commits
mailing list