Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Efficient SQL
Message
 
 
To
02/10/2014 17:11:24
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01608703
Message ID:
01608705
Views:
58
>Hi All:
>
>The following SQL takes 5 seconds to run. Is there any way to speed it up?
>
>I should mention that on my local machine it runs very quickly. The problem is when I run this on the user's network.
>
>Note that line_close is a field in the poline table.
>
>
>SELECT 'P' sqcType, reqrd_date sqdDate, ;
>	ord_qty - recv_qty sqnQty, 0000000 sqnRunning,  ;
>	' ' sqcIgnore ;
>	FROM a_poline pl ;
>	WHERE Item_no = tcItem ;
>	AND pl.ord_qty > pl.recv_qty ;
>	AND !line_close ;
>	UNION ALL ;
>	SELECT 'S' sqcType, sh.canc_date sqdDate, ;
>	qty * -1 sqnQty, 0000000 sqnRunning,  ;
>	' ' sqcIgnore ;
>	FROM a_lineitm li ;
>	INNER JOIN a_sohead sh ;
>	ON li.so_no = sh.so_no ;
>	WHERE Item_no = tcItem ;
>	AND (sh.STATUS = 'S' OR sh.STATUS = 'b') ;
>	ORDER BY 2, 1 ;        &&Date
>INTO CURSOR curRunning READWRITE
>
>
>Thanks,
>
>Yossi

You can move last condition on sh status table into the JOIN, e.g.
ON a_sohead sh ON li.so_no = sh.so_no and sh.Status IN ('S','b')

I don't think it'll speed it up. Do you have indexes on JOIN conditions and on item_no column?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform