Which is Quicker? Loop or filter a dataset....

M

Mark

Hi - when working with datasets, is it quicker to loop through the
dataset, comparing some column values with predetermined values, or
should I apply a filter on the dataset to retrieve the values I want?

(background - I'm populating an appointment calendar for consultants,
and need to check around 30 dates at a time dates for each of the 45
consultants - so I retrieve all appointments between the start date, and
the startdate + 30 days - into the dataset - I then need to find out if
a consultant has an appointment on any date in the range, and then loop
onto the next date, and then the next consultant, and populate a table
with all of this info at once).

Thanks for any guidance,

Mark
 
K

Karl Seguin

Mark,
My guess is applying a filter will be quicker...but the difference will
probably be almost unnoticeable..

My real answer is to simply test it out...you can easily build both and
check which takes longer to run (might need to do it more than 1 times
though to actually start seeing a difference)...

Karl
 
J

John Saunders

Mark said:
Hi - when working with datasets, is it quicker to loop through the
dataset, comparing some column values with predetermined values, or
should I apply a filter on the dataset to retrieve the values I want?

The simple answer is, "it depends". ;-)

You are talking about a very small amount of data, all of which will be in
memory. Chances are that nobody will ever notice the difference in
performance between the best case and the worst case. Consider: what if one
technique took 0.001 seconds and another took 1 second? In a web-based
application, the time it takes to send the HTML to the client will be large
enough that nobody will notice the difference.

John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top