Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange SQL Speed
Message
From
18/10/2000 18:18:54
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00431066
Message ID:
00431220
Views:
11
No deleted records in either file. Of course the same is true for the cursors.

>Well, you forget about deleted fields. Note that subquery runs for each record. If your table contains a lot of deleted records, they must be filtered out. In your second sample you queried both tables into cursor filtering out deleted records. Than make query on clear data. Following is formula (I don't think it is exact, but at least it gives main idea):
>
>ND1 - number of all records in table 1
>ND2 - number of all records in table 2
>N1 - number of not deleted records in table 1
>N2 - number of not deleted records in table 2
>
>Speed difference will be:
>k*( N1* (ND2-N2) + (ND1-N1) )
>Where k is time required to check if record is deleted.
>As you see, the more deleted records you have, the more is difference between tables with deleted records and non-deleted.
>
>For second sample difference is following:
>k*((ND2-N2) + (ND1-N1))
>
>Finally, time difference for both samples will be:
>k*((N1-1)*(ND2-N2) )
>
>Quite significant!
>
>
>>Thanks for the reply. This takes about the same 1000 seconds as the original query. I think the speed issue has to do with the use of a cursor vs. a table even though the cursor exists on the hard drive the same as the table does.
>>
>>>>In VFP 6, two free tables, table1 (739,068 records) and table2 (609,862 records) each has a fieldx which is a 7 byte long character representation of a number which is unique within each table. Each table has an index tag on fieldx. The following:
>>>>
>>>>SELECT fieldx FROM table2 WHERE fieldx NOT IN (SELECT fieldx FROM table1)
>>>
>>>Try following query:
>>>
>>>SELECT fieldx FROM table2 WHERE NOT EXISTS (SELECT fieldx FROM table1 where table1.fieldx=table2.fieldx)
>>>
>>>If table1 and table2 indexed by fieldx field, you should have good speed.
>>>
>>>
>>>>
>>>>This correctly return 31,183 records in 1002.50 seconds.
>>>>
>>>>SELECT fieldx FROM table1 INTO CURSOR tab1 NOFI
>>>>SELECT fieldx FROM table2 INTO CURSOR tab2 NOFI
>>>>SELECT fieldx FROM tab2 WHERE fieldx NOT IN (SELECT fieldx FROM tab1)
>>>>
>>>>This correctly return 31,183 records in 25.60 seconds.
>>>>
>>>>Before each run I made sure that VFP was the only process running on the Windows 95 machine. Pretty strange.
Previous
Reply
Map
View

Click here to load this message in the networking platform