OkonomiDev
Monday, September 22, 2003
      ( 1:27 PM ) Matt  

Lazy Evaluation


Imagine you have a database with servers in 3 remote locations. The three servers are connected via the internet. Most queries executed at any of the three locations only require data from the local server. Some queries require data from one of the other two. Now, imagine that one of the three servers goes down. Determining which queries can still be executed and which ones can't is a real problem that database programs have. You don't want the other two to be foreced to shut down just because of one failing machine.


Enter lazy evaluation.


A lazy language determines what information is needed when it is needed, not when it is planning how to execute it. A lazy query language would solve this problem. Any queries which really do need data on the down server would be put on hold while all other queries continued executing. Queries which need data from a query that's on hold would also have to wait.


Putting queries on hold doesn't make people happy. Replication can be used to address this problem. If all of the data is replicated on at least two out of the three machines, then if one goes down, another will have the data available. Can lazy languages help here? Sure. Consider the coalase function:


coalese(a, b) { return (a==null)?b:a; }


Simply put, if the first source is unavailable, return the value from the second source. In a lazy language b is not queried unless a is unavailable.

# -




Comments: Post a Comment
archives:


Dreams I have...

Powered by Blogger
Feel free to e-mail me.

free hit counter