In a program, there are times when I can retrieve the same data either on a shared database or on a server connected in a lan. Which one should I choose regarding speed (and other considerations maybe) ?
An opened connection to the database AND an opened socket are already available when I need to make that decision.
Dependent on how you have setup access to your database, they will probably both use TCP/IP to access either. So, the performance will be roughly the same. If you have a file with the data in, you have to open the file and then read the contents. Comparing that to a database connection, you have to open a database connection and execute some SQL to get the results. I actually think that the main part of your question relies on what type of data your are actually wanting to store.