Translate

Saturday, January 19, 2013

Database Administra​tion - PASS DBA Virtual Chapter Live Meeting Event

Date: January 23rd, 2013

Noon Eastern Time – http://www.timeanddate.com/worldclock/fixedtime.html?msg=PASS+DBA+Virtual+Chapter+Live+Meeting&iso=20130123T12&p1=198&ah=1

Topic: Revenge: Resource Governor – sponsored by Quest Software

Presenter: Dinesh Asanka

Abstract:

Resource Governor is a new technology introduced in SQL Server 2008 that enables you to manage SQL Server workload and resources by specifying limits on resource consumption by incoming requests.

Bio: Dinesh Asanka has been an MVP in SQL Server since 2008 and has been working with SQL Server since 1999. He has worked with SQL Server versions 7, 2000, 2005, 2008, 2012. He currently works as Production DBA and supporting a 24X7 database system. He has contributed to five SQL Server books, is Co-founder of SQL Server Sri Lankan User Group and actively works to promote SQL Server in Sri Lanka. He has presented at Tech Insight 2011, Malaysia.He is also a lecturer at Sri Lanka Institute of Information Technology for Proactive Database Administrator and Data ware House & Data Mining and is a contributing editor at SQL Server Performance.com

Door prize: There will be a raffle for a $100 Amazon gift certificate. You do not need to register for the meeting, but if you want to enter the raffle, you must register at https://www.livemeeting.com/lrs/8000181573/Registration.aspx?pageName=f3b4gtqq6qlp0bcb no later than 5:00 PM EST on January 22.

Live Meeting Link: https://www.livemeeting.com/cc/8000181573/join?id=BQ2D94&role=attend

Note: the meeting will be recorded and available on the meeting archives page at dba.sqlpass.org about a week after the event.

How to Get pageId for Each Record

This many not be something you can use in your application. This will be helpful during demonstrations of SQL Serve internals.

This sample code will tells you which row is in which page. Highlighted section has undocumented function.

  1: USE tempdb
  2: GO
  3: 
  4: CREATE table tblLoc
  5: (ID BIGINT IDENTITY,
  6: fld1 CHAR(1000) DEFAULT 'ABC',
  7: DATE1 Date DEFAULT GETDATE()
  8: )
  9: 
 10: INSERT INTO tblLOC
 11: 
 12: VALUES (DEFAULT,DEFAULT)
 13: GO 10000
 14: 
 15: SELECT * FROM tblLOC T
 16: CROSS APPLY fn_PhysLocCracker  (%%PHYSLOC%%) pl
 17: 

Result of this is,


image


SlotId is the record id of the page.

Saturday, January 5, 2013

NOLOGGING In Oracle Databases

In Oracle there is a valuable feature where you can disable logging for only one table. In SQL Server maximum granularity you have is database level. So in case, you are doing lot of inserts or index rebuilding for only one table you have the option of disabling the logging for that table.

ALTER TABLE t1 NOLOGGING;

So above command will suspend the logging for table t1,


Only the following statements can make use of nologging:



Alter Table




  • Move Partition

  • Split Partition

  • Add Partition

  • Merge Partition

  • Modify Partition

Alter Index



  • Split Partition

  • Rebuild

  • Rebuild Partition

Create Table


Create Index


More info from following links


http://www.orafaq.com/wiki/Nologging_and_force_logging


http://www.adp-gmbh.ch/ora/misc/nologging.html


http://www.dba-oracle.com/t_nologging_append.htm


So I think it is good feature to have for SQL Server as well.

Monday, December 31, 2012

Too Many VLFs

Transaction Log consists of Virtual Log Files. When transaction log is increase virtual log files are crated according to following table. More info here

Log Size # of VLFs
64MB and up to 64MB 4
64MB and up to 1GB 8
larger than 1GB 16

Too many VLFs will lead to some problems like, backups will take long time, replication latency will be high. In fact, I have a bad experience, when one of the database has high replication latency and reason for that is high VLFs.

In SQL Server 2012, there is a new feature when the VLFs are more than 10,000 there will be an warning in the error log once the server startup.

During the CTP3 of Denali, this threshold was set to 1,000 but was increased at the RTM. However, Microsoft has forgot to reset the warning message. Winking smile

Here is how I recreate this.

image

I verified number of VLFs by DBCC LOGINFO(). I verified that there are no warning when log file reached the 1000 VLFs.

After reaching 10,000 I saw the error message but it says database has  more than 1000 virtual log files.

image

Friday, December 28, 2012

Top 10 Cloud Stories Of 2012

Here’s a list of the Cloud Computing Exchange’s 10 most-read stories in 2012:

Wednesday, December 26, 2012

How to measure the percentage of online index rebuild

 

Rebuilding indexes online is time consuming hence many DBAs need to monitor the event. There is a profiler event in SQL Profiler to capture the online index rebuilding.

In SQL Profiler, there is an event Progress Report: Online Index Operation under Progress Report category.

clip_image002

When this profiler is executing results can be obtained. Most of the columns are common like application name, database name spid , login etc. However, there are few uncommon columns which are shown in the below image.

clip_image004

Index ID – index ID from for the table.

Object Name : Index Name

BigIntData1: 0 = serial plan; otherwise, the thread ID during parallel execution.

BigIntData2: Number of rows inserted.

In the above example, non-clustered index BigintData2 in 0 which means index rebuild was done using a serial plan. In that example if you consider the BigintData1, it shows the cumulative rows rebuild. Since this table has 20,000 records last row for BigintData2 shows that number.

If you consider the clustered Index, there are 8 parallel plans have created to rebuild the indexes. If you sum all the max value for each plan, that again adds up to 20,000.

Saturday, December 15, 2012

Left Outer Join , What is the Outer Join Table

I was little surprised when I heard the following statement which is,

When you are using Left Outer Join (even in Right Outer Join), Left joined table is defined by the ON condition not by the OUTER JOIN clause.

This means,

SELECT A.Column1, B.Column2

FROM A OUTER JOIN B ON A.ID = B.ID

Will give you every thing from the table A and from table B it gives you what only matches.

If you re-write the query, (You will notice that only change is, ON condition which is switched now)

SELECT A.Column1, B.Column2

FROM A OUTER JOIN B ON B.ID = A.ID

Will give you every thing from the table B and from table A it gives you what only matches.

What do you think?

Let us try it,

This is my sample data.

image

So let me try with two queries,

imageimage

Well, there is no truth what so ever.