Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL - really slow. How can I speed it up-indexing?
Message
From
12/02/2004 16:43:19
 
 
To
12/02/2004 16:15:20
John Vlahos
V I Software Solutions Design
Mississauga, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00876858
Message ID:
00876870
Views:
21
Hi John,

Since you can not reliably index on upper(alltrim(CSTATUS)), I suggest you make an index on upper(CSTATUS). And you need an index on cWorkOrderID in ROLLS.

And I recommend these changes:
lcTextToSearch=padr("REJECTED",20) && change 20 to the length of the cSTATUS field. 
lcWorkOrderNo=SALEORDER_ITEMS.cWorkOrderNo && Whenever possible keep what you search for in a variable!!!
SELECT * FROM ROLLS WHERE UPPER((cSTATUS)==lcTextToSearch AND ROLLS.cWorkOrderID == lcWorkOrderNo ORDER BY nRoll INTO CURSOR tmpRejected

lcWorkOrderNo=SALEORDER_ITEMS.cWorkOrderNo && Whenever possible keep what you search for in a variable!!!
SELECT * FROM ROLLS WHERE UPPER(cSTATUS)==lcTextToSearch AND ROLLS.cWorkOrderID == lcWorkOrderNo ORDER BY nRoll INTO CURSOR tmpAccepted

lcTextToSearch=SALEORDER_ITEMS.cWorkOrderNo && Whenever possible keep what you search for in a variable!!!
SELECT nWeight_Roll, ;
SUM(nWeight_Roll) AS nWeight_Skid, ;
SUM(nWeight_Roll_Metric) AS nWeight_Skid_Metric, ;
SUM(nUPerRoll) AS nUnits_Skid, ;
SUM(nFootage_Roll) AS nFootage_Skid, ;
cSkidID ;
FROM ROLLS ;
WHERE ROLLS.cWorkOrderID = lcTextToSearch ;
GROUP BY 6 ;
ORDER BY 6 ;
INTO CURSOR tmpSkid
>I have such statements when adding production items to my table (ROLLS). These statements undoubtedly slow down the operation which varies from computer to computer, depending on it's speed, but is even relatively slow with a Pentium IV.
>
>Is there anything I can do to really speed up the execution of these SQL statements and also not jeopordize theintegrity of the results?
>
>SELECT * FROM ROLLS WHERE UPPER(ALLTRIM(cSTATUS))=="REJECTED" AND ROLLS.cWorkOrderID == SALEORDER_ITEMS.cWorkOrderNo ORDER BY nRoll INTO CURSOR tmpRejected
>
>SELECT * FROM ROLLS WHERE UPPER(ALLTRIM(cSTATUS))=="ACCEPTED" AND ROLLS.cWorkOrderID == SALEORDER_ITEMS.cWorkOrderNo ORDER BY nRoll INTO CURSOR tmpAccepted
>
>SELECT nWeight_Roll, ;
>SUM(nWeight_Roll) AS nWeight_Skid, ;
>SUM(nWeight_Roll_Metric) AS nWeight_Skid_Metric, ;
>SUM(nUPerRoll) AS nUnits_Skid, ;
>SUM(nFootage_Roll) AS nFootage_Skid, ;
>cSkidID ;
>FROM ROLLS ;
>WHERE ROLLS.cWorkOrderID = SALEORDER_ITEMS.cWorkOrderNo ;
>GROUP BY 6 ;
>ORDER BY 6 ;
>INTO CURSOR tmpSkid
Previous
Reply
Map
View

Click here to load this message in the networking platform