<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Slow query in Invoice Against Sales Delivery menu]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=4528</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=4528&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Slow query in Invoice Against Sales Delivery menu.]]></description>
		<lastBuildDate>Fri, 22 Nov 2013 06:38:03 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Slow query in Invoice Against Sales Delivery menu]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18517#p18517</link>
			<description><![CDATA[<p>Updated <a href="https://github.com/apmuthu/frontaccounting/commit/854c8067faa29399b655ac317d0d1ace48c3c622">my personal GitHub Repo</a>.</p><p>Patch attached here.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Fri, 22 Nov 2013 06:38:03 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18517#p18517</guid>
		</item>
		<item>
			<title><![CDATA[Re: Slow query in Invoice Against Sales Delivery menu]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18515#p18515</link>
			<description><![CDATA[<p>Thank you for your response. Now I feel confident to add the index into my production system.</p><p>I&#039;ll try to implement the query optimization too.</p>]]></description>
			<author><![CDATA[null@example.com (mfaa98)]]></author>
			<pubDate>Fri, 22 Nov 2013 04:46:14 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18515#p18515</guid>
		</item>
		<item>
			<title><![CDATA[Re: Slow query in Invoice Against Sales Delivery menu]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18501#p18501</link>
			<description><![CDATA[<p>Must we now add the following in:<br /></p><div class="codebox"><pre><code>ALTER TABLE `0_debtor_trans` ADD INDEX `Order` (`order_`);</code></pre></div><p>We also need to optimise the query in the function at line 364 in <strong>sales/includes/db/cust_trans_db.inc</strong> to be:<br /></p><div class="codebox"><pre><code>function get_sql_for_sales_deliveries_view($selected_customer, $selected_stock_item=null)
{
    $sql = &quot;SELECT trans.trans_no,
            debtor.name,
            branch.branch_code,
            branch.br_name,
            sorder.deliver_to,
            trans.reference,
            sorder.customer_ref,
            trans.tran_date,
            trans.due_date,
            (ov_amount+ov_gst+ov_freight+ov_freight_tax) AS DeliveryValue,
            debtor.curr_code,
            Sum(line.quantity-line.qty_done) AS Outstanding,
            Sum(line.qty_done) AS Done
        FROM &quot;
         .TB_PREF.&quot;sales_orders as sorder LEFT JOIN &quot;
         .TB_PREF.&quot;debtor_trans as trans 
            ON (sorder.order_no = trans.order_) LEFT JOIN &quot;
         .TB_PREF.&quot;debtor_trans_details as line 
            ON (line.debtor_trans_no = trans.trans_no
                AND line.debtor_trans_type = trans.type) LEFT JOIN &quot;
         .TB_PREF.&quot;debtors_master as debtor
            ON (trans.debtor_no = debtor.debtor_no) LEFT JOIN &quot;
         .TB_PREF.&quot;cust_branch as branch 
            ON (trans.branch_code = branch.branch_code
                AND trans.debtor_no = branch.debtor_no)
        WHERE
            trans.type = &quot;.ST_CUSTDELIVERY;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Thu, 21 Nov 2013 16:37:49 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18501#p18501</guid>
		</item>
		<item>
			<title><![CDATA[Slow query in Invoice Against Sales Delivery menu]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18442#p18442</link>
			<description><![CDATA[<p>I have problem in Invoice Against Sales Delivery menu. It displays correctly, but the query is long (in my localhost experience, about 9 seconds).</p><p>After looking at the query and the database, there was small issues in the field order_ at table debtor_trans. The order_ field is not indexed. So after I add the index, the query now run normally (under half second)</p><p>Is it intended not to create index for field order_ or is it a performance bug?</p><p>Thank you.<br />Sorry for my bad English.</p>]]></description>
			<author><![CDATA[null@example.com (mfaa98)]]></author>
			<pubDate>Wed, 13 Nov 2013 23:29:03 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18442#p18442</guid>
		</item>
	</channel>
</rss>
