Code Optimization

Interesting things in software development and code optimization

How to handle SQL Server problems on shared and other hostings

Does your hosting have sql server problems all the time or from time to time? Do you lose data because of sql server issues? If yes then this post may be good case for you.


I use my own technique to backup critical data to HDD.

If there is any sql server issue then my code does backup of critical data to HDD and then restores that data from HDD when sql server back and running well.


Sure, just storing data into file(s) on hdd is really not good case (or even worse). You will need a lot of code to handle concurrency, navigation, select and find data, ordering and much more, and it is the place where LiteDB comes in to scene.


So my logic is simple:

- is there an exception while saving data into SQL Database?

- take that data and store it into LiteDB

- create a scheduled task to check if SQL Server issue has gone and do insert/update your SQL Database

- successfully inserted/updated? remove the data from LiteDB otherwise keep trying until success.


LiteDB uses single HDD file to store data and provides SQL-like functionality to operate your data.


Really simple and useful technique to avoid losing critical and important data. Also I show notification to related user that there are some pending data so users would not be disappointed.


Thank you :)


1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Comments (1) -

  • Emmitt Ives

    10/18/2018 11:38:25 AM | Reply

    I really like your writing style, excellent information, appreciate it for posting Laughing. "In every affair consider what precedes and what follows, and then undertake it." by Epictetus.

Loading