Differences in using functions on the server and on the client

There are significant differences between using the client version of the time series API (tsfeapi) and the server version of the time series API (tsbeapi).

The client and server interfaces do not behave in exactly the same way when updating a time series. This is because tsbeapi operates directly on a time series, whereas tsfeapi operates on a private copy of a time series. This means that updates through tsbeapi are always reflected in the database, while updates through tsfeapi are not. For changes made by tsfeapi to become permanent, the client must write the updated time series back into the database.

Another difference between the two interfaces is in how time series are passed as arguments to the mi_exec_prepare_statement() function. On the server, no special steps are required: a time series can be passed as is to this function. However, on the client you must make a copy of the time series with ts_copy and pass the copy as an argument to the mi_exec_prepare_statement() function.

There can be a difference in efficiency between the client and the server APIs. Functions built to run on the server take advantage of the underlying paging mechanism. For instance, if a function must scan across 20 years worth of data, the tsbeapi interface keeps only a few pages in memory at any one time. For a client program to do this, the entire time series must be brought over to the client and kept in memory. Depending on the size of the time series and the memory available, this might cause swapping problems on the client. However, performance depends on many factors, including the pattern of usage and distribution of your hardware. If hundreds of users are performing complex analysis in the server, it can overwhelm the server, whereas if each client does their portion of the work, the load can be better balanced.