Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Hint to load entire table into RAM before execution?

I'm running some aggregation queries on some very large tables in an OLAP environment. I'm currently bottlenecked by disk IO at 200 MB/s.

I'm doing these queries on a machine with 92 GB of RAM. Is there any SQL hint I can write into my query that basically tells SQL to load the entire table into RAM before execution?

Something like:

select * from myTable with (ramdisk)

I am using MS TSQL.

like image 588
John Shedletsky Avatar asked Feb 26 '13 17:02

John Shedletsky


People also ask

How do I pull an entire table in SQL?

How do you show all data in a table? The first command you will need to use is the SELECT FROM MySQL statement that has the following syntax: SELECT * FROM table_name; This is a basic MySQL query which will tell the script to select all the records from the table_name table.

What is Noexpand in SQL?

NOEXPAND. Specifies that any indexed views are not expanded to access underlying tables when the query optimizer processes the query. The query optimizer treats the view like a table with clustered index. NOEXPAND applies only to indexed views.


1 Answers

No. The database engine will do this automatically if it has enough space in the page cache.

You can set the amount of memory being used by using SQL Server Management Studio. Right click on the server, choose the memory option, and put a large number in the "Minimum Server Memory" box. If you have 92 Gbytes of RAM, then a number like 85,000 is probably good. You need to leave additional memory for the operating system and other services on the machine.

Assuming the table(s) fit into memory, this should facilitate processing. If they don't fit into memory, then you might have to take another approach.

like image 75
Gordon Linoff Avatar answered Nov 15 '22 00:11

Gordon Linoff