Reputation: 203
I use ODBC to query a table from a database:
getTable(Ref,SearchKey) ->
Q = "SELECT * FROM TestDescription WHERE NProduct = " ++ SearchKey,
case odbc:sql_query(Ref,Q) of
{_,_,Data} ->
%io:format("GetTable Query ok ~n"),
{ok, Data};
{error,_Reason} ->
%io:format("Gettable Query error ~p ~n",[_Reason]),
{stop, odbc_query_failed};
_->
io:format("Error Logic in getTable function ~n")
end.
This function will return a tuple which includes all the db data. Sending this to another process:
OtherProcessPid!{ok,Data};
It works fine with a small number of rows, but how about a very large number, greater than a million, say? Can erlang still work with it?
Upvotes: 4
Views: 1461
Reputation: 9648
The question isn't "Can Erlang handle very large messages?" (it can), it is rather "are you ready to deal with the consequences of very large messages?"
All messages are copied (exception of some larger binaries): this means you have to prepare for some slowdowns if you're doing a lot of messaging of large messages, have memory use a lot less stable than with small messages, etc.
In the case of distributed Erlang, a very large message that needs to be 'uploaded' to a remote node might block the heartbeats making it possible to know whether a VM is alive or not if the delays are too short, or the messages too large for how often you send them.
In any case, the solution is to measure what you can or can't deal with. There is no hardcoded limit that I know of regarding message size. Know that smaller messages are usually preferable as a general rule of thumb, though.
Upvotes: 9