Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 5 Monaten, 3 Wochen
Letzter Beitrag:
vor 5 Monaten, 3 Wochen
Beteiligte Autoren:
Arie, Ruben Sanchez Peña, Curtis, Rasta

[WD22] Optimizing data search speed

Startbeitrag von Rasta am 27.12.2017 16:48

Greetings,

I created a report that displays Items that were not sold during the selected period.


This is my current code:

HFilter(STOCK,Store_Number,COMBO_STORE.COL_Store_Number,COMBO_STORE.COL_Store_Number)
HReadFirst(STOCK)


nRecRead is int
nTotal is int = HNbRec(STOCK)

WIN_WAIT.PROGBAR_WAIT_WINDOW = 0
WIN_WAIT.PROGBAR_WAIT_WINDOW..MaxValue = nTotal


HReadSeekFirst(ITEM,Item_Number,STOCK.Item_Number)

WHILE HOut(STOCK) = False

nRecRead += 1
WIN_WAIT.PROGBAR_WAIT_WINDOW = nRecRead

IF STOCK.Quantity

Antworten:

SQL Queries. They will almost always be faster than a bunch of hFunctions.

von Curtis - am 27.12.2017 17:27
Hi.

You are scrolling through the complete file so that HFilter checks whether or not a record meets the query conditions.

If your HF is in HF/CS then create a query that runs the search on the server and returns only the results that meet the query. This will allow successive queries to make use of the HF cache and be faster.

Then you can use a FOR EACH loop to browse the records returned by query.

Rubén

von Ruben Sanchez Peña - am 29.12.2017 11:27
Rasta,

create a query on the STOCK file including an LEFT OUTER JOIN to the ITEMS_SOLD file and a LEFT OUTER JOIN to the ITEMS_PROCUREMENTS file.
It will give you NULL-values for both joined files if there is NOT a corresponding record.
You can then loop trhought the result set and test for these null-values.

Also a "NOT IN" query will work.
SELECT * FROM stock WHERE item_number NOT IN ( put the code of our QRY_Items_Sold here....)

You have to try for yourself which option is the fastest. It depends on your situation.

Not to mention that you need proper indexes on all your files.

von Arie - am 30.12.2017 09:18
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.