Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will index be fully loaded into memory

I am wondering whether the index will be fully loaded into memory or not?

like image 934
user496949 Avatar asked Oct 28 '25 14:10

user496949


2 Answers

The answer to this is in several parts:

  1. The size of the index.
  2. What parts are accessed.
  3. Memory pressure.

I had a huge index on a table that took SQL Server a full 3 minutes to return the first result. Second query (different request) was about one minute. Third query was 20 seconds. Eventually all results came in 0.001 seconds.

The point? SQL Server cached the index in memory as it was being read.

However, if I had put other memory pressure on SQL Server, it would have dropped out those cached index pages by order of lowest reads.

like image 136
IamIC Avatar answered Oct 31 '25 05:10

IamIC


No, it's treated like any other data stored on disk. It's loaded into memory disk page by disk page. And a page stays in memory as long as it's regularly accessed.

like image 45
Codo Avatar answered Oct 31 '25 05:10

Codo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!