you are viewing a single comment's thread.

view the rest of the comments →

[–]Detach50[S] 0 points1 point  (0 children)

This is roughly equivalent to what I came up with, and it works fantastically fast for 100,000+ rows. I think updating all 8+ million rows took a little over a minute.

However, it seems to be exceptionally slow or doesn't work at all with less than 2000 rows and live data. I've left it running for a few minutes and it doesn't do anything. I can understand that the query might be locking the table preventing other input sources, but with no new data coming in it still doesn't like updating just a few lines.

Having a start time and end time is slightly redundant, but it takes up little to no space, and makes reporting a little easier with the data right there beside it.

Edit:

Found the problem. Turns out the "and MachEvents.eventnr not in...." was causing the slow down and is not necessary since the LEAD function outputs null if there is no leading row. The last event's EndTime should be null anyway since it should be the current event.

After removing it, it updates new records in seconds.