Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New to Views
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00459334
Message ID:
00459392
Views:
25
Excellent post, thank you.

>If no ORDER BY clause is used then you get all records matching the WHERE criteria in the natural order of the table.
>
>FoxPro uses a binary tree format for its indexes. This means that equal values are always added to the right. Rushmore uses the indexes to retrieve a bitwise variable that specifies which records are to be returned. This variable is built using the natural order of the table because an index is built by scanning the table and adding new index nodes in the appropriate place (to the left if < and to the right >=).
>
>Ex.
>              E
>             /  \
>            C    L
>           / \     \
>          A   C     M
>               \
>                C
>Taking the above tree representation, the specifics are:
>Record      Value      Secondary Field
>1             E             6
>2             L             9
>3             C            10
>4             A             3
>5             C             2
>6             M            16
>7             C             1
>If you do a simple select on value = "C" without an order by clause, nodes 3, 5 and 7 will be returned in the following representation:
>0010101
>
>VFP will build a cursor based on that representation. If you specify an order by clause (e.g. on the secondary field) then VFP has to go through an extra operation to sort the previosly built cursor on the new expression.
>
>FWIW, SQL Server is the same way. Bring up the Execution Plan in Query Analyzer and you can see the extra step visually represented.
Chris McCandless
Red Sky Software
Previous
Reply
Map
View

Click here to load this message in the networking platform