ASp.Net day

Micro blog

Sql server cpu utilisation

April 23
by Satalaj 23. April 2010 08:50

 Days ago I wanted to know which query is taking lots of time and cpu utilisation for execution.
and I came to one blog from where I copied below query. It tells details of all query. You need to fire it on your SQL server to know more.

SELECT
    substring(text,qs.statement_start_offset/2
        ,(CASE   
            WHEN qs.statement_end_offset = -1 THEN len(convert(nvarchar(max), text)) * 2
            ELSE qs.statement_end_offset
        END - qs.statement_start_offset)/2)
    ,qs.plan_generation_num as recompiles
    ,qs.execution_count as execution_count
    ,qs.total_elapsed_time - qs.total_worker_time as total_wait_time
    ,qs.total_worker_time as cpu_time
    ,qs.total_logical_reads as reads
    ,qs.total_logical_writes as writes
FROM sys.dm_exec_query_stats qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
    LEFT JOIN sys.dm_exec_requests r
        ON qs.sql_handle = r.sql_handle
ORDER BY 3 DESC

Could not allocate space for object 'dbo.SORT temporary run storage

April 22
by Satalaj 22. April 2010 06:58
Msg 1105, Level 17, State 2, Line 1
Could not allocate space for object 'dbo.SORT temporary run storage:  162245511741440' in database 'tempdb' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.


 It happens when you don't have enough space on your Drive where your tempDb database is lockated. You can avoid this by freeing up some space on that drive or
 Restart MS SQL server. After restarting of SQL server it will freeup temp db size.

Note:* Do not restrict auto grow size of .MDF or .LDF file.

Satalaj

Send SMS and Pepsi Can

April 21
by Satalaj 21. April 2010 07:36

     I heard that Reliance communication is offering services like send sms and get Pepsi can out of vending machine.
  Click here to know more. My guess,how it works at the back end. 
  When user sends SMS to mobile number displayed on vending machine, it shows user mobile number and 
  screen to choose products from vending machine. Once user completes the transaction vending machine software submits 
  transaction details to Reliance communication and they charges their post paid customers as per what they had purchaced
  from vending machine. 
    Well, I don;t think that solution is feasible. There are chances that message will be delayed or undlivered to vending machine.
  so, instead of SMS end user needs to do actual call to that machine mobile number and pickup vending machine phone after ring. 
  During transaction LCD should display menu which will display items to select. user need to select appropriate items then vending machine 
  should submit transaction details to service providers. As soon as phone call ends transaction needs to be commited.
 
-Satalaj.

Shared hosting or Dedicated hosting

April 21
by Satalaj 21. April 2010 06:33

 What is differance between shared hosting and dedicated hosting?
well, here is little brief information about it. When you plan to get your web site live, you need to purchace domain (the actual name or url).
Once you get that domain name you need to buy some space where you can store your pages,images and databases.
Some domain name providers provides free space along with your domain. However its not add free. So, all of your pages hosted with that sservice prvidres
will serve default adds.
Shared hosting:
 It comes with limited access. You will manage content of your web using their control panel
 You will be restricted to load extra third party executables on your server.

Dedicated hosting
 You will be given complete access to remote machine. You can remotely upload the contents
of your site like how you access your local network server using remote desktop.
You will not be restricted to install any third party executables on that machine.

Shared hosting is best choice for those who are having mini web sites.
Dedicated hosting is better if you have big web sites or portals and requires total
control on hosting server using remote desktop.

MS SQL server Transaction commit rollback

April 19
by Satalaj 19. April 2010 12:21

To know your transaction is getting rolled back you need to generate an exception.

This will ensure that transcation is rolled back.

Trick is very simple, just write statement select 1/0 at the end bo transaction block as shown in below query.

select 1/0 will generate an exception and your transaction needs to be rolled back.

Begin transaction MyTransactionName

begin try

-- Delete some rows from sql server
-- insert deleted rows into other table

select 1/0  -- This will generate an exception and your transaction needs to be rolled back

commit transaction MyTransactionName

End try

begin catch

rollback transaction MyTransactionName

end catch

END

If you are using linked server, you need to enable MSDTC services (Microsoft distributed transaction co-ordinates).

session loss in webgarden

April 19
by Satalaj 19. April 2010 11:33


Web Garden:

 In webGarden scenario application pool can have multiple worker process assigned to it.
In this case there are possiblilities like users first requests get served by workerprocess A and second request
get served by worker process B. assuming you are using In-proc session, in above scenario your worker process A
has user session and worker process B was not aware of it so when user tries to request the page and page was serverd by worker process B.
Then ultimately user will be asked to reinitiate the session.
 To overcome this situateion you need to mark the objects of classes who participate into session storing mechanisum as serializable
and you need to define the storage space for Session values like Application state server or SQL server for maintaining session state.
Why do we need to mark the classes a serializable? 
Objects while crossing the boundries of application they need to mark as serializable otherwise it's not posible for them to cross the boundries.

Application Pool recycling and session values

 When application pool pro-actively or re-actively recycles the healty/ un-healthy worker process and incase you are using in-process memory for
storing the session values, you will loose the session values. To avoid loosing session values use out of process session storing mechanisum.
use either SQL server or State server.

Web Farm:
In web farm scenario multiple machine act like single one using Network load balancing cluster. In this case there are possibilities that
first request get serverd by Machine A and second request get server by machine B of NLB cluster. If session get stored in Machine A's in process,
how is it possible to have those session value at machine b's in process. To avoid this we need to store session values as shared resource like
SQL server or State server.
I learned NLB using this article http://www.west-wind.com/presentations/loadbalancing/networkloadbalancingwindows2003.asp

To let SQL server participate into session storing mechanisum you need to execute aspnet_regSQL with appropriate switch.

-Satalaj


 

Load images faster

April 17
by Satalaj 17. April 2010 12:51

 If you found that your images are getting rendered at cleint little slower, you need to consider use of httpHandler to handle the images.
so, before image getting rendered at client side you can compress it.
Also, makesure that in IIS Keep-Alive is checked or set to On. Keep-Alive ensures that client's all requests are served via single connection to serer.
requests can be anyting like page is requesting image from server or CSS from server or Java scrits from server. There would be 90% boost in loading stuff at cleint side.
If Keep-Alive is to Off, client side browser opens new connection to the server for all requests like get image, css and javascript.
Making new connection to the server is very costly. You can see this performance gain by your own.

Fiddler v 2.x beta bug and web crowler

April 15
by Satalaj 15. April 2010 15:04


Well, fiddler is very nice tool to monitor outgoing request from your IE or AspNet development server to any third party web.

Fiddler is good tool to analyse the request going through IE. After monitoring the requests parameters posted to any web
one can write a program to crowl that web.  best way use C#.net for programming crowler.

You can download Fiddler from here
http://www.fiddler2.com/Fiddler2/version.asp

Latest Fiddler beta version 2.x for .net framework has bug

After 25000 to 50000 request fiddler throws MemoryExceptions. I tested it with 1GB and 2Gb ram on windows XP
with .net Framework 2.0 with latest service pack.

Satalaj

Tags:

General

database in recovery

April 12
by Satalaj 12. April 2010 09:52

If database suddenly went in to in recovery mode, due to less available space for transaction, you can fire below query and bring it live

USE master
GO
ALTER DATABASE pubs
SET QUOTED_IDENTIFIER ON, RECOVERY FULL, MULTI_USER

Simple Recovery
Simple Recovery allows the database to be recovered to the most recent backup.

Full Recovery
Full Recovery allows the database to be recovered to the point of failure.

Bulk-Logged Recovery
Bulk-Logged Recovery allows bulk-logged operations.


Congratulations 2010 Microsoft MVP

April 03
by Satalaj 3. April 2010 09:54

I'm very happy for being recognised as MVP.


Dear Satalaj More,

Congratulations! We are pleased to present you with the 2010 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in ASP/ASP.NET technical communities during the past year.

Also in this email:

About your MVP Award Gift
How to access www.mvpaward.com to begin taking advantage of your award benefits
Your MVP Identification Number
MVP Award Program Code of Conduct
The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say "Thank you for your technical leadership."

Toby Richards
General Manager
Community & Online Support

 

Tags:

Asp.net

About Satalaj

My name is Satalaj. I'm 2010 asp.net MVP. I write technical stuff here. www.satalaj.com

Ads by Lake Quincy Media

The best inline translator

Live lookup to see what asp.net developers are searching