[freeside-commits] freeside/FS/FS cust_pkg.pm,1.119,1.120
Ivan,,,
ivan at wavetail.420.am
Sun Mar 29 04:52:24 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv32058
Modified Files:
cust_pkg.pm
Log Message:
seems to benchmark faster, RT#5083
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- cust_pkg.pm 29 Mar 2009 10:17:02 -0000 1.119
+++ cust_pkg.pm 29 Mar 2009 11:52:22 -0000 1.120
@@ -1580,20 +1580,37 @@
my $pkgnum = $self->pkgnum;
my $pkgpart = $self->pkgpart;
+# qsearch( {
+# 'table' => 'part_svc',
+# 'hashref' => {},
+# 'extra_sql' =>
+# "WHERE 0 = ( SELECT COUNT(*) FROM pkg_svc
+# WHERE pkg_svc.svcpart = part_svc.svcpart
+# AND pkg_svc.pkgpart = ?
+# AND quantity > 0
+# )
+# AND 0 < ( SELECT COUNT(*) FROM cust_svc
+# LEFT JOIN cust_pkg USING ( pkgnum )
+# WHERE cust_svc.svcpart = part_svc.svcpart
+# AND pkgnum = ?
+# )",
+# 'extra_param' => [ [$self->pkgpart=>'int'], [$self->pkgnum=>'int'] ],
+# } );
+
+#seems to benchmark slightly faster...
qsearch( {
- 'table' => 'part_svc',
- 'hashref' => {},
- 'extra_sql' =>
- "WHERE 0 = ( SELECT COUNT(*) FROM pkg_svc
- WHERE pkg_svc.svcpart = part_svc.svcpart
- AND pkg_svc.pkgpart = ?
- AND quantity > 0
- )
- AND 0 < ( SELECT COUNT(*) FROM cust_svc
- LEFT JOIN cust_pkg using ( pkgnum )
- WHERE cust_svc.svcpart = part_svc.svcpart
- AND pkgnum = ?
- )",
+ 'select' => 'DISTINCT ON (svcpart) part_svc.*',
+ 'table' => 'part_svc',
+ 'addl_from' =>
+ 'LEFT JOIN pkg_svc ON ( pkg_svc.svcpart = part_svc.svcpart
+ AND pkg_svc.pkgpart = ?
+ AND quantity > 0
+ )
+ LEFT JOIN cust_svc ON ( cust_svc.svcpart = part_svc.svcpart )
+ LEFT JOIN cust_pkg USING ( pkgnum )
+ ',
+ 'hashref' => {},
+ 'extra_sql' => "WHERE pkgsvcnum IS NULL AND cust_pkg.pkgnum = ? ",
'extra_param' => [ [$self->pkgpart=>'int'], [$self->pkgnum=>'int'] ],
} );
}
More information about the freeside-commits
mailing list