Index: /branches/version-2_13-dev/data/class/SC_Product.php
===================================================================
--- /branches/version-2_13-dev/data/class/SC_Product.php	(revision 23406)
+++ /branches/version-2_13-dev/data/class/SC_Product.php	(revision 23422)
@@ -625,38 +625,7 @@
     public function alldtlSQL($where_products_class = '')
     {
-        if (!SC_Utils_Ex::isBlank($where_products_class)) {
-            $where_products_class = 'AND (' . $where_products_class . ')';
-        }
-        /*
-         * point_rate, deliv_fee は商品規格(dtb_products_class)ごとに保持しているが,
-         * 商品(dtb_products)ごとの設定なので MAX のみを取得する.
-         */
-        $sub_base = "FROM dtb_products_class WHERE del_flg = 0 AND product_id = dtb_products.product_id $where_products_class";
-        $sql = <<< __EOS__
-            (
-                SELECT
-                     dtb_products.*
-                    ,dtb_maker.name AS maker_name
-                    ,(SELECT MIN(product_code) $sub_base) AS product_code_min
-                    ,(SELECT MAX(product_code) $sub_base) AS product_code_max
-                    ,(SELECT MIN(price01) $sub_base) AS price01_min
-                    ,(SELECT MAX(price01) $sub_base) AS price01_max
-                    ,(SELECT MIN(price02) $sub_base) AS price02_min
-                    ,(SELECT MAX(price02) $sub_base) AS price02_max
-                    ,(SELECT MIN(stock) $sub_base) AS stock_min
-                    ,(SELECT MAX(stock) $sub_base) AS stock_max
-                    ,(SELECT MIN(stock_unlimited) $sub_base) AS stock_unlimited_min
-                    ,(SELECT MAX(stock_unlimited) $sub_base) AS stock_unlimited_max
-                    ,(SELECT MAX(point_rate) $sub_base) AS point_rate
-                    ,(SELECT MAX(deliv_fee) $sub_base) AS deliv_fee
-                    ,(SELECT COUNT(*) $sub_base) AS class_count
-                FROM dtb_products
-                    LEFT JOIN dtb_maker
-                        ON dtb_products.maker_id = dtb_maker.maker_id
-                WHERE EXISTS(SELECT * $sub_base)
-            ) AS alldtl
-__EOS__;
-
-        return $sql;
+        $objDBFactory = SC_DB_DBFactory_Ex::getInstance();
+
+        return $objDBFactory->alldtlSQL($where_products_class);
     }
 
Index: /branches/version-2_13-dev/data/class/db/SC_DB_DBFactory.php
===================================================================
--- /branches/version-2_13-dev/data/class/db/SC_DB_DBFactory.php	(revision 23378)
+++ /branches/version-2_13-dev/data/class/db/SC_DB_DBFactory.php	(revision 23422)
@@ -216,3 +216,65 @@
         return $sql;
     }
+
+    /**
+     * 商品詳細の SQL を取得する.
+     *
+     * @param  string $where_products_class 商品規格情報の WHERE 句
+     * @return string 商品詳細の SQL
+     */
+    public function alldtlSQL($where_products_class = '')
+    {
+        if (!SC_Utils_Ex::isBlank($where_products_class)) {
+            $where_products_class = 'AND (' . $where_products_class . ')';
+        }
+        /*
+         * point_rate, deliv_fee は商品規格(dtb_products_class)ごとに保持しているが,
+         * 商品(dtb_products)ごとの設定なので MAX のみを取得する.
+         */
+        $sql = <<< __EOS__
+            (
+                SELECT
+                     dtb_products.*
+                    ,T4.product_code_min
+                    ,T4.product_code_max
+                    ,T4.price01_min
+                    ,T4.price01_max
+                    ,T4.price02_min
+                    ,T4.price02_max
+                    ,T4.stock_min
+                    ,T4.stock_max
+                    ,T4.stock_unlimited_min
+                    ,T4.stock_unlimited_max
+                    ,T4.point_rate
+                    ,T4.deliv_fee
+                    ,T4.class_count
+                    ,dtb_maker.name AS maker_name
+                FROM dtb_products
+                    INNER JOIN (
+                        SELECT product_id,
+                            MIN(product_code) AS product_code_min,
+                            MAX(product_code) AS product_code_max,
+                            MIN(price01) AS price01_min,
+                            MAX(price01) AS price01_max,
+                            MIN(price02) AS price02_min,
+                            MAX(price02) AS price02_max,
+                            MIN(stock) AS stock_min,
+                            MAX(stock) AS stock_max,
+                            MIN(stock_unlimited) AS stock_unlimited_min,
+                            MAX(stock_unlimited) AS stock_unlimited_max,
+                            MAX(point_rate) AS point_rate,
+                            MAX(deliv_fee) AS deliv_fee,
+                            COUNT(*) as class_count
+                        FROM dtb_products_class
+                        WHERE del_flg = 0 $where_products_class
+                        GROUP BY product_id
+                    ) AS T4
+                        ON dtb_products.product_id = T4.product_id
+                    LEFT JOIN dtb_maker
+                        ON dtb_products.maker_id = dtb_maker.maker_id
+            ) AS alldtl
+__EOS__;
+
+        return $sql;
+    }
 }
Index: /branches/version-2_13-dev/data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php
===================================================================
--- /branches/version-2_13-dev/data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php	(revision 23295)
+++ /branches/version-2_13-dev/data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php	(revision 23422)
@@ -283,3 +283,48 @@
         return $objQuery->getCol($col, $from, $where);
     }
+
+    /**
+     * 商品詳細の SQL を取得する.
+     *
+     * PostgreSQL 用にチューニング。
+     * @param  string $where_products_class 商品規格情報の WHERE 句
+     * @return string 商品詳細の SQL
+     */
+    public function alldtlSQL($where_products_class = '')
+    {
+        if (!SC_Utils_Ex::isBlank($where_products_class)) {
+            $where_products_class = 'AND (' . $where_products_class . ')';
+        }
+        /*
+         * point_rate, deliv_fee は商品規格(dtb_products_class)ごとに保持しているが,
+         * 商品(dtb_products)ごとの設定なので MAX のみを取得する.
+         */
+        $sub_base = "FROM dtb_products_class WHERE del_flg = 0 AND product_id = dtb_products.product_id $where_products_class";
+        $sql = <<< __EOS__
+            (
+                SELECT
+                     dtb_products.*
+                    ,dtb_maker.name AS maker_name
+                    ,(SELECT MIN(product_code) $sub_base) AS product_code_min
+                    ,(SELECT MAX(product_code) $sub_base) AS product_code_max
+                    ,(SELECT MIN(price01) $sub_base) AS price01_min
+                    ,(SELECT MAX(price01) $sub_base) AS price01_max
+                    ,(SELECT MIN(price02) $sub_base) AS price02_min
+                    ,(SELECT MAX(price02) $sub_base) AS price02_max
+                    ,(SELECT MIN(stock) $sub_base) AS stock_min
+                    ,(SELECT MAX(stock) $sub_base) AS stock_max
+                    ,(SELECT MIN(stock_unlimited) $sub_base) AS stock_unlimited_min
+                    ,(SELECT MAX(stock_unlimited) $sub_base) AS stock_unlimited_max
+                    ,(SELECT MAX(point_rate) $sub_base) AS point_rate
+                    ,(SELECT MAX(deliv_fee) $sub_base) AS deliv_fee
+                    ,(SELECT COUNT(*) $sub_base) AS class_count
+                FROM dtb_products
+                    LEFT JOIN dtb_maker
+                        ON dtb_products.maker_id = dtb_maker.maker_id
+                WHERE EXISTS(SELECT * $sub_base)
+            ) AS alldtl
+__EOS__;
+
+        return $sql;
+    }
 }
