In db I have : (have = existing situation. the DB has already has the data)
Long html string (nvarchar max)
user have :
asp.net aspx page
mission:
extract from the whole html string 1 specific sentence – and show it to user
options :
1) do the strip job in sql and transfer the result to the client
pros: network is not loaded with the whole html – but the result
cons : sql server is working harder
2) send the whole html in the wire to the server and do the job there.
pros : sql is not working too hard , iis do the job with ready-tools ( html agilitypack)
cons : network wire is loaded with unwanted data
which approach is the right one ?
p.s.
lets assume that the hardware is excellent.
If you need to retrieve this specific piece of data repeatedly you should store it separately – in another column on the same table, for example.
When saving the HTML, extract this piece of information for storage (also on update, to ensure that the information stays in sync).
I would suggest using an HTML parser like the HTML Agility Pack to parse and query the HTML and doing it in the ASP.NET code that will save to the DB instead of doing it in the DB (as string manipulation does not have great support in databases).
This has the benefit of only retrieving the data when you need it and processing only when required.