0

いくつかの webSQL テーブルを更新するコードがありますが、それは別のトランザクション内の別のトランザクション内のトランザクションです。テーブルの更新にはかなりの時間がかかりますが、値の作成/挿入には通常の時間がかかります。WebSQL トランザクションのパフォーマンスを確認する方法はありますか (所要時間は?)

webService への AJAX Sucess コールバック内に、次のコードがあります。

function handleOrderNote(value, tx, ite) {
tx.executeSql('SELECT * FROM MobileOrder where MobileOrderID = ?', [value.mobileOrder.mobileOrderID],
    function (tx, result) {
        function updateCreateOrderNote(tx, result, nResultadosIn, ite) {
            if (nResultadosIn > 0) {
                function updateOrderNote(value2, tx, ite) {
                    tx.executeSql('UPDATE MobileOrder SET CompanyID =?, CustomerID =?, OrderDate = ?, TotalQtt = ?, TotalCost = ?, UserPHC=?, HeaderID=?, OrderState=?, Observations=?, Status = ? WHERE MobileOrderID = ?', [value2.mobileOrder.companyID, value2.mobileOrder.customerID, value2.mobileOrder.orderDate, value2.mobileOrder.totalQtt, value2.mobileOrder.totalCost, value2.mobileOrder.userPHC, value2.mobileOrder.headerID, value2.mobileOrder.orderState, value2.mobileOrder.observations, value2.mobileOrder.status, value2.mobileOrder.mobileOrderID],
                        function (tx, result) {
                            function searchEqualOrderNote(value3, tx, ite) {
                                tx.executeSql('SELECT * FROM MobileOrderDetail where MobileOrderDetailID = ?', [value3.mobileOrderDetailID],
                                    function (tx, result) {
                                        function updateCreateLineOrderNote(tx, result, nResultadosIn, ite, value3) {
                                            if (nResultadosIn > 0) {
                                                function updateLineOrderNote(value4, tx, ite) {
                                                    tx.executeSql('UPDATE MobileOrderDetail SET MobileOrderID =?, Ref =?, CompanyID = ?, Discount = ?, Qtt = ?, TotalDetail=?, DetailID=? WHERE MobileOrderDetailID = ?', [value4.mobileOrderID, value4.ref, value4.companyID, value4.discount, value4.qtt, value4.totalDetail, value4.detailID, value4.mobileOrderDetailID],
                                                        function (tx, result) {}
                                                    );
                                                }
                                                updateLineOrderNote(value3, tx, ite);
                                            } else {
                                                function createLineOrderNote(value4, tx, ite) {
                                                    tx.executeSql('INSERT INTO MobileOrderDetail (MobileOrderDetailID, MobileOrderID, Ref, CompanyID, Discount, Qtt, TotalDetail, DetailID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', [value4.mobileOrderDetailID, value4.mobileOrderID, value4.ref, value4.companyID, value4.discount, value4.qtt, value4.totalDetail, value4.detailID],
                                                        function (tx, result) {});
                                                }
                                                createLineOrderNote(value3, tx, ite);
                                            }
                                        }

                                        updateCreateLineOrderNote(tx, result, result.rows.length, ite, value3);
                                    });
                            }
                            for (var i = 0; i < value2.mobileOrderDetail.length; i++) {
                                var linhaNotaEncomenda = value2.mobileOrderDetail[i];
                                searchEqualOrderNote(linhaNotaEncomenda, tx, i);
                            }
                        }
                    );
                }
                updateOrderNote(value, tx, ite);
            } else {
                function createOrderNote(value2, tx, ite) {
                    tx.executeSql('INSERT INTO MobileOrder (IDLocal, MobileOrderID, CompanyID, CustomerID, OrderDate, TotalQtt, TotalCost, UserPHC, HeaderID, OrderState, Observations, Status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [idLocalDestaEncomenda, value2.mobileOrder.mobileOrderID, value2.mobileOrder.companyID, value2.mobileOrder.customerID, value2.mobileOrder.orderDate, value2.mobileOrder.totalQtt, value2.mobileOrder.totalCost, value2.mobileOrder.userPHC, value2.mobileOrder.headerID, value2.mobileOrder.orderState, value2.mobileOrder.observations, value2.mobileOrder.status],
                        function (tx, result) {
                            function searchEqualOrderNote(value3, tx, ite, idLocalInput) {
                                tx.executeSql('SELECT * FROM MobileOrderDetail where MobileOrderDetailID = ?', [value3.mobileOrderDetailID],
                                    function (tx, result) {
                                        function updateCreateLineOrderNote(tx, result, nResultadosIn, ite, value3) {
                                            if (nResultadosIn > 0) {
                                                function updateLineOrderNote(value4, tx, ite) {
                                                    tx.executeSql('UPDATE MobileOrderDetail SET MobileOrderID =?, Ref =?, CompanyID = ?, Discount = ?, Qtt = ?, TotalDetail=?, DetailID=? WHERE MobileOrderDetailID = ?', [value4.mobileOrderID, value4.ref, value4.companyID, value4.discount, value4.qtt, value4.totalDetail, value4.detailID, value4.mobileOrderDetailID],
                                                        function (tx, result) {}
                                                    );
                                                }
                                                updateOrderLine(value3, tx, ite);
                                            } else {
                                                function createLineOrderNote(value4, tx, ite) {
                                                    tx.executeSql('INSERT INTO MobileOrderDetail (MobileOrderDetailID, MobileOrderID, Ref, CompanyID, Discount, Qtt, TotalDetail, DetailID, IDLocal) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', [value4.mobileOrderDetailID, value4.mobileOrderID, value4.ref, value4.companyID, value4.discount, value4.qtt, value4.totalDetail, value4.detailID, idLocalInput],
                                                        function (tx, result) {
                                                            //trata linhas de encomenda
                                                        });
                                                }
                                                createLineOrderNote(value3, tx, ite);
                                            }
                                        }
                                        updateCreateLineOrderNote(tx, result, result.rows.length, ite, value3, idLocalInput);
                                    });
                            }
                            for (var i = 0; i < value2.mobileOrderDetail.length; i++) {
                                orderLine = value2.mobileOrderDetail[i];
                                searchEqualOrderNote(orderLine, tx, i, idLocalDestaEncomenda);
                            }
                        });
                }
                createOrderNote(value, tx, ite);
            }
        }
        updateCreateOrderNote(tx, result, result.rows.length, ite);
    });

}

4

1 に答える 1

0

トランザクションを再利用すると、パフォーマンスが劇的に向上するはずです。

トランザクションを再利用するには 2 つの方法があります。

複数の tx from を使用するdb.transactionことで、並列リクエストを取得します。

onsuccess ハンドラーからの tx を再利用することで、順序付けされたシリアル リクエストを取得します。

于 2013-04-03T05:15:59.967 に答える