Skip to content

Get the most out of MSSQL !

Consultant & Trainer for all things MSSQL

  • Home
  • Company
  • Business Intelligence
  • Simply Better Business

In Memory OLTP – New feature in SQL 2014

Posted on May 1, 2014March 20, 2021 by jayanth.kurup

We saw this coming with the demand for highly transaction database becoming more frequent clubbed with the need to store data in very large sets. Naturally one precludes the other. BI required more data to be collected and stored which resulted in performance of queries to reduce since the base table got larger without any real improvements to the way the developer wrote code or changes to the optimizer to find better execution plans.

In memory OLTP is a shortcut that allows you to now store datasets in RAM while still following ACID principals. The advantages are tremendous. We see that every system has a few core transactional tables or reference tables that are used the most. By putting these tables in RAM we take advantage of

  • Better IO since RAM has always been faster than IO
  • Better use of the way SQL has always handled RAM, the more the better.
  • Since In Memory OLTP doesn’t use the traditional PAGE approach there are fewer concurrency issues.
  • Access to RAM based structures especially since they no longer use PAGE algorithms meant there needed to be a new way to arrive at the execution tree for procedures. This is generally faster.

There is a lot to cover on this topic so today we are going to stick to just how to implement it. It is important to note that the name is In Memory OLTP, what this means is that for OLAP system you would still end up using ColumnStore indexes (which are now updatable).

In order to implement In Memory OLTP one of the first things you need to do is create an In-Memory file group. This can be done via the UI or T-SQL.

Please keep in mind that In-Memory OLTP requirements are in addition to normal RAM requirements the server has for regular operations and tables that do not reside in RAM. Plan accordingly. Also once a File group is created for Memory optimized data you cannot get rid of it without dropping the database.

If you have a table that you want to move into the RAM, you should right click the Table in SSMS and run the Memory Optimize Advisor. MSDN recommends that the amount of RAM and disk space allocated should be double to the size of the table being used. Mainly to account for versioning.

It runs a number of checks in order to determine if the table meets the criteria to become an In memory table

Please read the above list is to understand what the restrictions are on the table. Right off the bat you will see that a lot of table in normal usage cases become ineligible. You cannot have compute columns; the table cannot be partitioned or replicated. Default constraints are not allowed.

The next screen shows a list of additional T-SQL Commands and operations that won’t work with In Memory tables. For a complete list click here.

In the next screen we are asked for some input

All the above inputs are self-explanatory except the last one. So let’s talk about it. As you know RAM is volatile which means that it can lose data in the event of a power failure. With IN Memory OLTP we now have ACID principles in effect for both the schema and data , what this means is that the tables stored in the RAM can be made durable for both the table schema as well as the data contained in it or only for the table and not for the data, This is akin to creating a temp workspace in the RAM and would be an excellent way to load staging tables in ETL processes going forward.

By checking the last box you’re effectively telling SQL not to worry about the data.

In the next screen we discuss the way the table would use indexes. As you can see there is a need to create a primary key which should not be that difficult since most tables have one. What matters more here is the type of non-clustered index structure used for the primary key (Primary Key does not always mean clustered index). E.g. you can use a traditional non clustered index if you have one; the traditional NC index works better for range lookups. When you want point lookups (very similar to key lookup) you would need to create a Non Clustered Hash Index which expected a bucket count. The bucket count needs to be calculated by the DBA and we will cover this in detail in a later post. For now we are going ahead with a traditional index first.

Once the requirement for PK is completed the next option you may get is to migrate the existing NC indexes into the new Hash format. For now we leave it as it is. Quick note about indexes in In-Memory tables is the collation plays an important part in whether the index is allowed or not.

The rest of the screens are just summary and progress information

When it’s done you will see the new table in Object explorer in SSMS

Once the database is created you can create an In Memory table simply by right clicking the table folder, most of the options for the create table syntax have already been explain above.

In the next post we are going to do a quick comparison of the performance of this table as File based and In Memory based.

Please Consider Subscribing

Subscribe

CategoriesDatabases, Performance TuningTagsaccess, account, Action, addition, administration, advantage, age, AI, algorithm, amount, Analysis Services, app, approach, ASP, aspx, AWS, Azure, Bangalore, Base Table, Bengaluru, Better, better use, BigData, BLR, box, buck, bucket count, Business Intelligence, CaL, case, cell, change, check, Cloud, Clustered, CLUSTERED INDEX, collation, column, ColumnStore index, command, comparison, Concurrency, constraint, Consultant, Consulting, Core, Corporate, count, CREATE, Create Table, CTE, currency, Data, database, datasets, day, dba, demand, detail, developer, development, disk, drop, E.g, effect, en-US, Enabled Business Solutions, enabledbusiness, end, etl, event, Excel, exe, exec, execution plan, expert, explorer, failure, file, File group, folder, form, format, group, hand, head, Highly, index, indexes, India, info, information, input, int, issue, issues, Jayanth, key, Kurup, lease, lib, library, lookup, lookups, lot, Mary, matter, mean, memory, memory OLTP, memory table, microsoft, Migration, min, mind, ML, move, ms sql server, MSBI, msdn, MSSQL, MYSQL, name, NC index, need, network, new table, non clustered, non-clustered index, note, number, object, OLAP, OLAP system, OLTP, operation, optimize, optimizer, option, Oracle, part, partition, performance, plan, png, point, post, power, power pivot, Power Query, PowerApps, PowerBI, Powershell, pre, PRIMARY, primary key, principle, procedure, process, progress, Python, quick comparison, quick note, RAM, rate, RDBMS, red, reference, Remote, requirement, restriction, result, run, Schema, security, server, set, show, shows, side, space, sql, SQL 2000, SQL 2005, SQL 2008, sql 2008 r2, sql 2012, SQL 2014, SQL 2016, SQL 2017, SQl 2019, SSAS, SSIS, SSMS, SSRS, staging tables, structure, SUM, summary, syntax, sys, T-SQL, T-SQL Command, tab, Tables, TABLE_SCHEMA, term, thing, Today, tools, topic, traditional index, trainer, Transact, Transaction, tree, tuning, type, Upgrade, uploads, usage, Very large database, Virtual, virtual machine, visual studio, VM, war, windows, work

jayanth.kurup

This post was written by Jayanth Kurup. A Microsoft SQL Server Consultant and Trainer based out of Bangalore, India. Jayanth has been working on MS SQL Server for over 15 years. He is a performance tuning and Business Intelligence expert. Having worked with companies like Microsoft, DELL, Wells Fargo, Thomson Reuters and many other fortune 100 companies. Some other technologies Jayanth works on include Microsoft Azure, PowerBI, Python and AWS. When he isn’t consulting or training, Jayanth like to travel, paint and read. He is also very active in social causes and the founder of Enabled Business Solutions. Visit his company by clicking the link in the menu or email him directly.

Post navigation

PreviousPrevious post: Forcing Innovation
NextNext post: MS SQL Performance tuning: – Partitioning explained

The Latest

  • Monty Hall Simulation using T-SQL April 5, 2022
  • Query to quickly profile a column February 7, 2022
  • Outlook 2019 keeps asking for password multiple times December 9, 2021
  • Part 2:- Learning T SQL for beginners – Datatypes September 28, 2021
  • Part 1:- Learning T SQL for beginners- SQL, Tables and Nulls September 27, 2021
  • Query to find execution time of Jobs July 28, 2021
  • A simple script to decapitalize Column names July 19, 2021
  • My personal side effects with Covishield June 27, 2021
  • Setting up and Configuring CUDA, CUDNN and PYTorch for Python Machine Learning. June 3, 2021
  • keras.utils.generic_utils’ has no attribute ‘populate_dict_with_module_objects May 30, 2021

Find By Category

  • Azure
  • Databases
  • Events
  • Performance Tuning
  • PowerBI
  • Uncategorized
  • Website Design

Archive

  • April 2022 (1)
  • February 2022 (1)
  • December 2021 (1)
  • September 2021 (2)
  • July 2021 (2)
  • June 2021 (2)
  • May 2021 (2)
  • April 2021 (5)
  • March 2021 (10)
  • January 2021 (2)
  • November 2020 (2)
  • October 2020 (3)
  • September 2020 (4)
  • August 2020 (6)
  • July 2020 (1)
  • June 2020 (32)
  • May 2020 (18)
  • April 2020 (2)
  • March 2020 (4)
  • February 2020 (5)
  • January 2020 (1)
  • December 2019 (1)
  • November 2019 (14)
  • October 2019 (3)
  • September 2019 (1)
  • July 2019 (3)
  • June 2019 (2)
  • May 2019 (1)
  • April 2019 (2)
  • March 2019 (1)
  • January 2019 (4)
  • December 2018 (2)
  • November 2018 (4)
  • September 2018 (6)
  • August 2018 (2)
  • July 2018 (3)
  • June 2018 (4)
  • May 2018 (1)
  • April 2018 (4)
  • March 2018 (3)
  • February 2018 (3)
  • January 2018 (1)
  • December 2017 (2)
  • November 2017 (4)
  • August 2017 (2)
  • July 2017 (5)
  • May 2017 (1)
  • March 2017 (3)
  • January 2017 (3)
  • December 2016 (2)
  • November 2016 (2)
  • October 2016 (4)
  • September 2016 (1)
  • August 2016 (1)
  • July 2016 (1)
  • June 2016 (1)
  • May 2016 (2)
  • April 2016 (1)
  • March 2016 (14)
  • February 2016 (10)
  • January 2016 (19)
  • December 2015 (3)
  • November 2015 (5)
  • October 2015 (10)
  • September 2015 (9)
  • August 2015 (16)
  • July 2015 (13)
  • June 2015 (4)
  • May 2015 (2)
  • April 2015 (2)
  • March 2015 (7)
  • February 2015 (3)
  • January 2015 (22)
  • December 2014 (1)
  • November 2014 (5)
  • October 2014 (12)
  • September 2014 (5)
  • August 2014 (7)
  • July 2014 (41)
  • June 2014 (9)
  • May 2014 (12)
  • April 2014 (32)

Members Only

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Proudly powered by WordPress