Beruflich Dokumente
Kultur Dokumente
[Top]
Run sp_who
• spid - server process identification number (use this with the kill command)
• status - state of this task:
o recv sleep - waiting to read data from the network
o send sleep - waiting to write data to the network
o alarm sleep - waiting for an alarm (e.g., the waitfor command)
o lock sleep - waiting to acquire a lock, or sleeping on a semaphore
o sleeping - waiting for client input or disk activity
o running - only one task per engine can be running
• loginame - login associated with this task
• origname -
• hostname - descriptive string passed from the client
• blk - zero, or spid of other task blocking this one
• dbname - name of database currently used by this task
• cmd - command this task is currently running
Run sp_lock
• fid -
• spid - server process identification number (use this with the kill command)
• locktype - kind of lock owned by this task:
o Sh_intent - shared intent, which may be implied by Sh_page
o Sh_page - shared page: a page is being read and cannot be changed
o Sh_table - shared table: nothing in the table can be changed
o Update_page - a lock that is being upgraded from shared to exclusive
o Ex_intent - exclusive intent, which may be implied by Ex_page
o Ex_page - exclusive page: a page is being updated
o Ex_table - exclusive table: a whole table is locked
• table_id - object identification number of the affected table
• page - zero, or number identifying the page that is locked
• dbname - database containing page or table that is locked
• class - information about the cursor holding the lock
• context -
[Top]
Run sp_monitor
sp_monitor
[Top]
Run sp_sysmon
sp_sysmon begin_sample
go
[run your test script here, or just wait while other stuff runs]
sp_sysmon end_sample
go
[Top]
Optimize SELECTs
[Top]
Optimize Cursors
• Check cursor plans using the cursor, not the standalone version of the select.
• Use union instead of or clauses or in lists.
• Explicitly specify for update or for read only.
• Include the of column_name_list when using for update.
• Use the default set close on endtran off to keep cursors open across
transactions.
• Avoid multiple connections, open multiple cursors on a single connection
instead.
•
•
•
[Top]
Set Showplan On
• For standalone SQL statements that you don't want to execute, use this in SQL
Advantage:
• set showplan on
• go
• set noexec on
• go
• ...your SQL statement(s) here
• go
• set showplan off
• go
• set noexec off
• end
• To see the plan for trigger logic, you have to execute the SQL statements:
• set showplan on
• go
• ...your insert/update/delete SQL statement(s) here
• go
• set showplan off
• go
• To see the plan for procedures called from triggers, you have to copy and paste
the procedure logic into SQL Advantage as if it was a standalone SQL batch.