Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Azure Database perform better with transactions

We decided to use a micro-orm against an Azure Database. As our business only needs "inserts" and "selects", we decided to suppress all code-managed SqlTransaction (no concurrency issues on data).

Then, we noticed that our instance of Azure Database responded very slowly. The "rpc completed" event occured in delays that are hundreds times the time needed to run a simple sql statement.

Next, we benchmarked our code with EF6 and we saw that the server responded very quickly. As EF6 implements a built-in transaction, we decided to restore the SqlTransaction (ReadCommited) on the micro-orm and we noticed everything was fine.

Does Azure Database require an explicit SqlTransaction (managed by code) ? How does the SqlTransaction influence Azure Database performances ? Why was it implemented that way ?

EDIT : I am going to post some more precise information about the way we collected traces. It seems our Azure events logs sometimes express in nanoseconds, sometimes in milliseconds. Seems so weird.

like image 995
Rénald Avatar asked Feb 05 '16 18:02

Rénald


People also ask

How can you improve the performance of SQL Azure databases?

There are three primary options for Automatic Tuning with Azure SQL Database: CREATE INDEX: Creates new indices that can improve the performance. DROP INDEX: Drops redundant and unused indices (>90 days) FORCE LAST GOOD PLAN: Identifies queries using the last known good execution plan.

Which is a key benefit of using Azure SQL Database compared to using SQL Server on-premises?

Key benefit of using Azure SQL database compared to using SQL server on-premises. In terms of performance, one of the key advantages of using Azure SQL database is, High availability, As per Microsoft, it is 99.99% availability service level agreement (SLA).

Does Azure SQL Database support distributed transactions?

A server-side distributed transactions using Transact-SQL are available only for Azure SQL Managed Instance. Distributed transaction can be executed only between Managed Instances that belong to the same Server trust group.


1 Answers

If I understand what you are asking correctly, batching multiple SQL queries into one transaction will give you better results on any DBS. Committing after every insert/update/delete has a huge overhead on a DBS that is not designed for it (like MyISAM on MySQL).

It can even cause bad flushes to disk and thrashing if you do too much. I once had a programmer committing thousands of entries to one of my DBs every minute, each as their own transactions, and it brought the server to a halt.

InnoDB, one of 2 most popular database formats for MySQL, can only commit 20-30 transactions a second (or maybe it was 2-3... it's been a long time), as each is flushed to the disk at the end for ACID compliance.

like image 90
Dakusan Avatar answered Oct 10 '22 05:10

Dakusan