Tutorials to .com

Tutorials to .com » Database » Foxpro » Foxpro RUSHMORE Technology

Foxpro RUSHMORE Technology

Print View , by: iSee ,Total views: 15 ,Word Count: 3008 ,Date: Fri, 17 Apr 2009 Time: 2:08 AM

First, the concept of

foxpro often encountered entering this Dongdong RUSHMORE, then what is it RUSHMORE? We all know that the use of the index to look up data will be much faster, such as the establishment of the index in the query field, seek to locate for much faster than that, this is because the use of index seek information, but did not locate for.

Well, can not be allowed to locate for the use of indexes can speed up the pace of this inquiry? RUSHMORE technology is the role of starting. Not only locate for, in fact, with all the commands for inquiries to be done, for example: count for that is statistics the number of eligible records, then it would be in line with the conditions necessary to query out the record. RUSHMORE technology and with for all orders to speed up the implementation of speed, it is also called query optimization.

Small knowledge

Why use the index query than those that do not use query as fast? General inquiries by the order of inquiries, such as a table in the 1000 records, the records meet the requirements in section 750, general inquiries on a record from the beginning, a comparison be eligible, until they found eligible, the is that it must be compared 750. If the record is based on small to large according to the order, you can not search by the order, you can check that section 500, if you need to find a record of 500 than the first, and then must meet the conditions in between 500-1000 by the same way from the middle of 500-1000 to check, you can find a 750, while 750 is looking for, so just get in touch with the needs of the two records.

Second, the use of

Do not think that the word seems difficult RUSHMORE difficult, in fact, is not difficult to use, generally you only need to set up the field index on the line, when there are for the implementation of the order, FOXPRO system automatically according to the index to query records in line with the conditions, you do not need to do anything, even the index will be required to set up the main index does not need, of course, if it is not structured composite index, you must query the index files before opening.

Third, the situation can not be used RUSHMORE

  1. If you use the scope in order clause may RUSHMORE will not work. We know that the scope of clause four: all, rest, next, record n (n is used to specify a record number), in which all and the rest will not affect the RUSHMORE, but if you are using the next and record n, then will not RUSHMORE role.
  2. If the index used for clause, then the index can not be used RUSHMORE, such as:
    index on the name for the basic wage> 200 tag gz
    This index on RUSHMORE no help.
  3. If the index used in expression. Not., Then the index can not be used RUSHMORE, such as:
    index on. not. delete () tag notdel
    In such cases you can set delete on, and then re-use without. Not. The index expression.
  4. When the order while the use of the clause.
  5. If you are less computer memory, RUSHMORE may not work. However, I would like to now the computer will rarely less memory.
  6. For an already sorted by an index of the table, can not be used RUSHMORE, is why you want to use the best RUSHMORE Before making an order or set order to use set order to 0 the command will be set up in the wrong index table under control, you do not have index must be shut down, the composite index can not be shut down. If some kind of order according to records sort order can be used to record the actual sort, of course, to weigh the pros and cons because the sort order is also very time-consuming, if the inquiry in order to save a little bit of time, and spent a lot of time to sort, it does not pay the. If the first sort will carry out a large number of inquiries, it also almost.

Of course, can not be used RUSHMORE order will not affect the normal execution, but speed will be slower, if it is a very large table, for example, millions of records, may be much slower.

Fourth, the expression can not be used RUSHMORE

FOR is not followed by all the expressions can be used to speed up query RUSHMORE speed, the following expression will not be able to optimize the use of RUSHMORE:

  1. With isblank () and empty () function of the expression can not be optimized, such as:
    locate for empty (name)
  2. Included with the expression of $ operator.
    locate for 'Ga' $ name
  3. Expression must be exact match with the index expression, such as:
    index on upper (cu_name) tag name & & index expression is the upper (cu_name)
    locate for cu_name = 'ACME' & & can not be optimized, because cu_name and upper (cu_name) is not exactly the same
    locate for upper (cu_name) = 'ACME' & & you can optimize the

Fifth, the optimal combination of expression

If it is a logical expression of the two operators. Or. Or. And. Mix up, the situation is more complex, the following table on the situation described:

Serial number Expression 1 Operator Expression 2 Results
1 Can be optimized . and. Can be optimized All can be optimized
2, Can be optimized . or. Can be optimized All can be optimized
Three Can be optimized . and. Can not be optimized Part can be optimized
Four Can be optimized . or. Can not be optimized Can not be optimized
5, Can not be optimized . and. Can not be optimized Can not be optimized
6, Can not be optimized . or. Can not be optimized Can not be optimized
7 -- . not. Can be optimized All can be optimized
Of 8 -- . not. Can not be optimized Can not be optimized
[AutoPage]

For example:

locate for name = 'crop'. and. Date <(12/30/96) & & is fully optimized, in keeping with article 1

locate for name = 'crop'. or. 'Gia' $ name & & can not be optimized, subject to section 4

locate for. not. name = 'crop' & & all can be optimized, subject to section 7

locate for. not. 'Gia' $ name & & can not be optimized, subject to section 8

Sixth, the complexity of the optimization of expression

The expression of the two combinations and then combined to form complex expressions, the optimization is even more complicated, Participation in the following table:

Serial number Expression 1 Operator Expression 2 Results
1 All can be optimized . and. All can be optimized All can be optimized
2, All can be optimized . or. All can be optimized All can be optimized
Three All can be optimized . and. Part can be optimized Part can be optimized
Four All can be optimized . or. Part can be optimized Part can be optimized
5, All can be optimized . and. Can not be optimized Part can be optimized
6, All can be optimized . or. Can not be optimized Can not be optimized
7 -- . not. All can be optimized All can be optimized
Of 8 Part can be optimized . and. Part can be optimized Part can be optimized
Of 9 Part can be optimized . or. Part can be optimized Part can be optimized
10 Part can be optimized . and. Can not be optimized Part can be optimized
11 Part can be optimized . or. Can not be optimized Can not be optimized
12 -- . not. Part can be optimized Can not be optimized
13 Can not be optimized . and. Can not be optimized Can not be optimized
14 Can not be optimized . or. Can not be optimized Can not be optimized
15 -- . not. Can not be optimized Can not be optimized

For example:

locate for (name = 'Johnston'. and. Birth Date <(^ 1967-12-30)). or. (name = 'Lee'. and. Birth Date> (^ 1966-12-30))

Can all be optimized, because the two combinations can be optimized expression are in line with Article 2.

locate for (name = 'Johnston'. and. Birth Date <(^ 1967-12-30)). and. 'Gia' $ name

Part can be optimized, because there is only one expression can be optimized in line with Article 5.

locate for (name = 'Johnston'. and. 'Gia' $ name). or. (name = 'Lee'. and. 'strong' $ name)

Part can be optimized, because the two are part of can be optimized in accordance with Article 9.

locate for ( 'Zhuang' $ name. or. 'Tianhe District,' $ address). or. ( 'LI' $ name. or. 'Baiyun District' $ address)

Can not be optimized, because the two are not optimized in line with Article 14.

Tips

Expression also refers to the complexity of the two complex expressions together again, or a combination of a simple expression with a combination of expression.

7, the closure of RUSHMORE

In some very exceptional circumstances RUSHMORE the results may lead to an incorrect order, such as the use of RUSHMORE order modified in the course of the for clause in the keyword index, of course, this kind of situation is rare, if there is such circumstances, it should be shut down RUSHMORE functions so that the closure of vfp system RUSHMORE, can be ordered as follows:

[AutoPage]

set optimize off

To open it is:

set optimize on

If only the closure of a RUSHMORE order to optimize a function, can be added in the order nooptimize clause, for example:

locate for name = 'crop' nooptimize

Eight to see the power of RUSHMORE

Running this procedure: rushmore.prg, you will know the stakes RUSHMORE, the source code is as follows:

set talk off
set safety off
close table all
clear

* Set up the path implied
DQML = SYS (5) + SYS (2003)
CXLJ = SYS (16)
FOR JSQ = 1 TO LEN (CXLJ)
CXZF = LEFT (RIGHT (CXLJ, JSQ), 1)
IF CXZF = '\'
CXLJ = STUFF (CXLJ, LEN (CXLJ)-JSQ +1, JSQ,'')
EXIT
ENDIF
ENDFOR
SET DEFAULT TO '& CXLJ'

if file ( 'sjb.dbf') & & if there sjb.dbf
use sjb index sjb & & open sjb.dbf and index
set order to 0 & & table set is not sorted by index, but keep the index open
else & & if there is no sjb.dbf
create table sjb (name c (10)) & & create sjb.dbf

index on name to sjb & & Indexing
set order to 0 & & table set is not sorted by index, but keep the index open
endif

if reccount () <300000 & & If the table does not have records of 300,000

@ 2,5 say 'is to generate data tables, please wait ...'

zap & & empty table

* In the table to add the same record 300,000
ks = second () & & record start time
for jsq = 1 to 300000
append blank
replace name with 'crops'

dq = second () & & record the current time
sysj = (dq-ks) / jsq * 300000 - (dq-ks) & & calculation of the remainder of

if mod (jsq, 5000) = 0 & & if 1000 can be jsq is divisible, that is, show the progress of every 1000 and the remainder
@ 2,30 say str (jsq/300000 * 100,3 )+'%' & & show the progress of the increase in
@ 2,40 say 'the rest:' + str (sysj, 4) + 'seconds' & & display the remaining time
endif
endfor

* Will be the 100th, replaced by another 290,000 records value
go 100
replace name with 'Chong-yu'
go 290000
replace name with 'Chong-yu'

endif

@ 4,5 say 'is the implementation of statistical operations, please wait ...'
set optimize off & & Close RUSHMORE Optimization
ks = second () & & recording the operation start time
count for name = 'Chong-yu' to jg & & operation statistics
js = second () & & recording the operation ending time
@ 4,5 say 'do not use RUSHMORE:' + str (js-ks, 5,3) + 'seconds, statistical results for:' + str (jg, 2) & & show the operation time

set optimize on & & open RUSHMORE Optimization
ks = second ()
count for name = 'Chong-yu' to jg
js = second ()
@ 6,5 say 'use RUSHMORE:' + str (js-ks, 5,3) + 'seconds, statistical results for:' + str (jg, 2)

* This is the doing of the following? Do not tell you first:)
?
? Chr (211) + chr (208)
?? Chr (181) + chr (227)
?? Chr (178) + chr (187)
?? Chr (207) + chr (224)
?? Chr (208) + chr (197)
?? Chr (215) + chr (212)
?? Chr (210) + chr (209)
?? Chr (181) + chr (196)
?? Chr (209) + chr (219)
?? Chr (190) + chr (166)
?? Chr (176) + chr (201)
?? Chr (163) + chr (161)

cancel

This program in a directory, and then use the following command in VFP implementation of the program:

do directory name \ rushmore


FoxPro Tutorial Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.