Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 8 Jahren, 10 Monaten
Letzter Beitrag:
vor 8 Jahren, 10 Monaten
Beteiligte Autoren:
Xavier, Milton, Piet van Zanten, Glenn Rathke

To QUERY or HFILTER that is the question

Startbeitrag von Glenn Rathke am 26.09.2009 16:09

I know it is a rather broad question but I'll ask anyway. Presuming the SQL table has all the appropriate indexes. When limiting a record set of a table in the initialization code, would it be better to use a Query with parameters or an Hfilter?

Code maintenance wise, I'm thinking a query with multuple params is easier to maintain than using a StringBuild.... but what about performance ?

Antworten:

Hi Glenn,

I prefer queries, becauses hfilter affects your data file directly.
If you use a query, you can still use the file outside the query with hCommands, because your query is an relatively independent instance of the file itself. With hFilter all hCommands are limited to the Filtered data only. Hreadseek may produce unexpected results. If you forget to switch off the filter, you can run into trouble.

If you use hfcs, then queries to me also seem a better option. I once used hFilter a lot, but I am replacing it now with queries. Once a quey is executed, most operations are handled in memory, so there's no charge for your server. Assuming memory is faster than disk operations, performance will be better. (However some caching options like opportunistic locking may result in very good performance of hCommands in hf classic too)

Regards,
Piet

von Piet van Zanten - am 26.09.2009 16:37
Hi Glenn,

I also used to use HFilter but have now switched exclusively to queries. From my somewhat limited understanding if you use HFilter you load the whole file but only display the filterd records whereas with a query it should be quicker since you only load the selected records.

I certainly noticed a big speed improvement on a file with 20,000 records when using quries as opposed to HFilter.

Milton

von Milton - am 27.09.2009 09:21
Hey Glenn,

if you can build the 'right' query, the query will be in most cases significant faster.

This doesn't mean that queries are always the best way to access data.
For example, if you know that you need to read exact one record, a HReadSeekFirst() is better than a query.

Xavier
WinDev/WebDev/Mobile consultant


von Xavier - am 27.09.2009 09:41
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.