Efficient difference between two progress queries

Status
Not open for further replies.
P

Pedro Matos

Guest
Can anyone explain me why when a I run a query in progress that acts only on one table it runs just in seconds and when i run same query but acting on two tables it runs in hours. Is there any wrong thing that I'm using ?

Example 1 (Quick query (secs))

DEF STREAM st1.

OUTPUT STREAM st1 TO c:\temp\teste.csv.

FOR EACH db.table_name1 NO-LOCK:

PUT STREAM st1 UNFORMATTED db.table_name1.atrr1 ";"
db.table_name1.atrr2 ";"
db.table_name1.atrr3 ";"

SKIP.
END.
OUTPUT STREAM st1 CLOSE.


Example 2 (fast query (hours))

DEF STREAM st1.

OUTPUT STREAM st1 TO c:\temp\teste.csv.

FOR EACH db.table1 NO-LOCK,
EACH db.table2 NO-LOCK


WHERE
AND table1.atrr2 = table2.atrr1:

PUT STREAM st1 UNFORMATTED /* Dados tabela loja */
db.table1.atrr1 ";"
db.table1.atrr2 ";"

/* Dados tabela cliente */

db.table2.atrr1 ";"
db.table2.atrr2 ";"
db.table2.atrr3 ";"

SKIP.
END.
OUTPUT STREAM st1 CLOSE.

Continue reading...
 
Status
Not open for further replies.
Top