Does the order of constrains, influences speed?

Posted by OctavioOlguin on 23-Dec-2016 15:27

Greetings these days!!!

I wanted to add a table to an already defined browse and came to this question:

I have a query this way:

FOR EACH table1 NO-LOCK,
   EACH table2 NO-LOCK
   WHERE Table1.Field1 = "somevalue"
   AND table1.field2 = table2.field1   // FK
   

and wanted to add table3,

and realized the following

FOR EACH table1 NO-LOCK,
   EACH table2 NO-LOCK,
   EACH table3 NO-LOK
   WHERE Table1.Field1 = "somevalue"
   AND table1.field2 = table2.field1   // FK
   AND table3.field1 = table1.field3   // FK

can be writen like this:

FOR EACH table1 NO-LOCK
   WHERE Table1.Field1 = "somevalue",
   EACH table2 NO-LOCK
   WHERE table1.field2 = table2.field1,   // FK
   EACH table3 NO-LOK
   WHERE table3.field1 = table1.field3   // FK

Is there some penalisation? overhead? or it is deep inside the engine some code to make look the first option like second option?

All Replies

Posted by Adriano Correa on 26-Dec-2016 10:23

I thought just the second example was right.

This thread is closed