On March 17th 2014 I spoke about Windows Azure SQL Database and your data at the Montreal .Net Community. During this presentation I shared details about how SQL Database differs from SQL Server and about my experiences with SQL Database.
5. @brisebois
• It’s a full SQL server
• It’s resources aren’t shared
• You must maintain and
patch the server
• No High Availability
• You will probably need an
I.T professional to help you
manage the Virtual Machine
http://bit.ly/1cReNGH
SQL Server Enterprise Edition on a Medium
VM (2 CPU, 3.5GB RAM) Costs $20,364/ Year
6. @brisebois
• It’s highly available
• It’s data is redundant (3 Copies)
• It’s response times are
unpredictable
• It doesn’t support a high volume
of concurrent queries
• It can be federated (scaled out)
• It’s constantly updated by
Microsoft
• It’s maintained by Microsoft
http://bit.ly/1cReNGH
SQL Database 150GB
Cost $2,709.36 / Year
15. @brisebois http://bit.ly/1iwpdvw
In a blog post “Uniqueidentifier and Clustered Indexes” the author points
out that the easiest and best approach to creating a Clustered Index is to
use a datetime2 column.
datetime2 has a resolution of 1/1000000 of a second
17. @brisebois http://bit.ly/Nopd4t
• If a CLUSTERED INDEX is present on
the table, then NONCLUSTERED
INDEXES will use its key instead of
the table ROW ID.
• To reduce the size consumed by the
NONCLUSTERED INDEXES it’s
imperative that the CLUSTERED INDEX
KEY is kept as narrow as possible.
18. @brisebois http://bit.ly/Nopd4t
• SQL Database can JOIN and
INTERSECT INDEXES in order to satisfy
a query without having to read data
directly from the table.
• Favor many narrow NONCLUSTERED
INDEXES
• Create Filtered INDEXES to create
highly selectivity
19. @brisebois http://bit.ly/Nopd4t
• Use Covering INDEXEs to reduce the
number of bookmark lookups required
to gather data that is not present in the
other INDEXES.
• Covering INDEXES can be used to
physically maintain the data in the
same order as is required by the
queries’ result sets reducing the need
for SORT operations.
20. @brisebois http://bit.ly/Nopd4t
• Covering INDEXES have an increased
maintenance cost, therefore you must
see if performance gain justifies the extra
maintenance cost.
• NONCLUSTERED INDEXES can
reduce blocking by having SQL
Database read from NONCLUSTERED
INDEX data pages instead of the actual
tables.
22. @brisebois http://bit.ly/1qMrE0N
Don’t Forget About Index Maintenance on
Windows Azure SQL Database
• On SQL Server, when we identify 5% to
30% of average fragmentation we should
issue a REORGANIZE statement
• On SQL Database we can only use the
REBUILD WITH (ONLINE =
ON) statement
27. @brisebois
• It’s highly availability
• It’s data is redundant (3 copies)
• It’s constantly updated by
Microsoft
• It’s maintained by Microsoft
• Can use services like a CDN
• The load is dispersed over many
services
http://bit.ly/1cReNGH
SQL Database 10GB + 100GB Blob
+ 100GB Table = Cost $803.52 /Year
29. @brisebois
• It’s highly availability
• It’s data is redundant (3 copies)
• It can handle + concurrent queries
that a 1 database
• It’s quite complex to backup
• It’s response time is unpredictable
• It’s constantly updated by
Microsoft
• It’s maintained by Microsoft
http://bit.ly/1cReNGH
SQL Database 5 * 10GB
Cost $2,757.24 /Year
30. @brisebois
• It has dedicated resources
• It’s response time is predictable
• It’s highly available
• It’s data is redundant (3 Copies)
• It’s maintained by Microsoft
• It can be sharded (scaled out)
• It’s constantly updated by
Microsoft
http://bit.ly/1cReNGH
SQL Database Premium P2 150GB
Cost $11,331 /Year (preview pricing)
37. @brisebois http://bit.ly/1gzhfB5
• Replace NewDatabaseName by the name
of the new Database
• Replace ServerName by the database
server name of the source Database
• Replace SourceDatabase by the name of
the source Database
40. @brisebois http://bit.ly/1hsOmEx
• 40501 – Retry to connect to SQL Database in intervals of 10 seconds until the resources are
available and your connection is established again.
• 40550 – The session has been terminated because it has acquired too many locks. Try reading or
modifying fewer rows in a single transaction.
• 40549 – Session is terminated because you have a long running transaction. Try shortening your
transaction.
• 40551 – The session has been terminated because of excessive TEMPDB usage. Try modifying
your query to reduce temporary table space usage.
• 40552 – The session has been terminated because of excessive transaction log space usage. Try
modifying fewer rows in a single transaction.
• 40553 – The session has been terminated because of excessive memory usage. Try modifying your
query to process fewer rows.
• 40545- The service is experiencing a problem that is currently under investigation.
• 40544 – The database has reached its size quota. Partition or delete data, drop indexes, or consult
the documentation for possible resolutions.
• 40174 – The partition is in transition and transactions are being terminated.
41. @brisebois
• It has been around since the early days of .Net and has been
tested thoroughly
• Can be used to repopulate the database
• Has change tracking through the DataRow RowState property.
• Is a 2 dimensional array with individually typed columns
• It can be consumed using Linq
http://bit.ly/1iwF8Ko
Master is read-onlyREAD COMMITTED SNAPSHOT does optimistic reads and pessimistic writes. In contrast, SNAPSHOTdoes optimistic reads and optimistic writes.When either the READ_COMMITTED_SNAPSHOT or ALLOW_SNAPSHOT_ISOLATION database options are ON, logical copies (versions) are maintained for all data modifications performed in the database. Every time a row is modified by a specific transaction, the instance of the Database Engine stores a version of the previously committed image of the row in tempdb. Each version is marked with the transaction sequence number of the transaction that made the change. The versions of modified rows are chained using a link list. The newest row value is always stored in the current database and chained to the versioned rows stored in tempdb.READ COMMITTED SNAPSHOT does optimistic reads and pessimistic writes. In contrast, SNAPSHOTdoes optimistic reads and optimistic writes.
CREATE TABLE [dbo].[TestTable] ( [Id] UNIQUEIDENTIFIER NOT NULL, [FirstName] NVARCHAR (10) NOT NULL, [LastName] NVARCHAR (10) NOT NULL, [Type] INT NOT NULL, [Timestamp] ROWVERSION NOT NULL, PRIMARY KEY (Id));
CREATE TABLE [dbo].[TestTable] ( [Id] UNIQUEIDENTIFIER NOT NULL, [FirstName] NVARCHAR (10) NOT NULL, [LastName] NVARCHAR (10) NOT NULL, [Type] INT NOT NULL, [Timestamp] ROWVERSION NOT NULL, PRIMARY KEY NONCLUSTERED (Id));CREATE CLUSTERED INDEX IX_TestTable on TestTable (FirstName, LastName);
CREATE CLUSTERED INDEX IX_TestTableON TestTable ([Type],[FirstName],[LastName])WITH (DROP_EXISTING=ON)ON [Primary]
CREATE CLUSTERED INDEX IX_TestTableON TestTable ([Type],[FirstName],[LastName])WITH (DROP_EXISTING=ON)ON [Primary]
CREATE CLUSTERED INDEX IX_TestTableON TestTable ([Type],[FirstName],[LastName])WITH (DROP_EXISTING=ON)ON [Primary]
CREATE INDEX [IX_TestTable_Country_City_LastName_FirstName] ON [dbo].[TestTable] ([Country] ASC,[City] ASC,[LastName] ASC,[FirstName] ASC) WITH(ONLINE=ON);
CREATE INDEX [IX_TestTable_Country_City_LastName_FirstName] ON [dbo].[TestTable] ([Country] ASC,[City] ASC,[LastName] ASC,[FirstName] ASC) WITH(ONLINE=ON);
CREATE INDEX [IX_TestTable_Country_City_LastName_FirstName] ON [dbo].[TestTable] ([Country] ASC,[City] ASC,[LastName] ASC,[FirstName] ASC) WITH(ONLINE=ON);
CREATE INDEX [IX_TestTable_Country_City_LastName_FirstName] ON [dbo].[TestTable] ([Country] ASC,[City] ASC,[LastName] ASC,[FirstName] ASC) WITH(ONLINE=ON);
CREATE INDEX [IX_TestTable_Country_City_LastName_FirstName] ON [dbo].[TestTable] ([Country] ASC,[City] ASC,[LastName] ASC,[FirstName] ASC) WITH(ONLINE=ON);
Go to portalCreate Clustered Indexes on the tables’ Natural Keys. Natural Keys, are the fields that best identify the row’s data. For example, the Primary Key used for a table might be a Unique Identifier or a Big Int, but I might access data through a combination of columns. For a car these columns could be Year, Make, Model and VIN. When you create the Clustered Index, order the columns by their selectivity and use this same order when you query for the information.Create Non-Clustered Indexes on your Primary KeysCreate Non-Clustered Indexes for all Foreign KeysCreate Non-Clustered Indexes for columns that are used in WHERE, ORDER BY, MERGE, JOIN and other clauses that require matching data.
Go to the portal
Maximum 150 GB
Geo Redundant Secondary Read Only Access
Sizes are set and the database des not automatically grow
dbForge Studio for SQL Server
CREATE DATABASE [NewDatabaseName] AS COPY OF ServerName.[SourceDatabase]SELECT * FROM sys.dm_database_copies
Transactions that take too long get killed or if the log goes over 2gb
Transactions that take too long get killed or if the log goes over 2gb
Transactions that take too long get killed or if the log goes over 2gb
Transactions that take too long get killed or if the log goes over 1gb