Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Last 10 records based on a condition
Message
De
01/01/2002 06:49:05
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
31/12/2001 11:23:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00599284
Message ID:
00599559
Vues:
17
>>>I need to get the last 10 records of a table based on a condition. However, that table is pretty big and I don't want to use the TOP 10 clause as it will take too long. What type of approach can I use which would be the best? I am looking for a SQL approach. If that is not possible then I'll consider using code.
>>
>>Michel,
>>IMHO with SQL approaches there would be some overhead whatever you do. I'd try traditional old xbas approach and I think it would be much faster :
>>
>>
>>select myTable
>>go bottom
>>afields(arrStruc)
>>create cursor crsResult from array arrStruc
>>select myTable
>>lnFound = 0
>>do while lnFound < 10 and !bof()
>>  if myCondition
>>    scatter memvar
>>    insert into crsResult from memvar
>>    lnFound = lnFound + 1
>>  endif
>>  skip -1
>>enddo
>>select crsResult
>>brow
Cetin
>
>Yes, but the problem with that is that some conditions will require several thousands of skip which will take longer for them.

Yes. However I tried it and it's at least two times faster in worst case (found recs need skip to first recs in table). It was 2-400 times faster compared to SQL.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform