Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

SQL Disk to Memory Expand / Collapse
Author
Message
Posted Tuesday, September 25, 2012 8:51 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 2:08 AM
Points: 1,380, Visits: 2,703
Hi all

I have a quick question regarding pages moving from disk into memory

If I select * from a table, are all pages that make up the table and indexes moved into memory?

So any subsequent query against that same table would not need to go to disk at all?

Thanks
Post #1364097
Posted Tuesday, September 25, 2012 9:15 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:38 PM
Points: 6,637, Visits: 14,220
SQLSACT (9/25/2012)
Hi all

I have a quick question regarding pages moving from disk into memory

If I select * from a table, are all pages that make up the table and indexes moved into memory?

So any subsequent query against that same table would not need to go to disk at all?

Thanks

for select * there is no index and yes, all data pages would be cached into memory


-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1364117
Posted Tuesday, September 25, 2012 9:19 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 8:21 AM
Points: 318, Visits: 1,084
Perry Whittle (9/25/2012)
SQLSACT (9/25/2012)
Hi all

I have a quick question regarding pages moving from disk into memory

If I select * from a table, are all pages that make up the table and indexes moved into memory?

So any subsequent query against that same table would not need to go to disk at all?

Thanks

for select * there is no index and yes, all data pages would be cached into memory


Doesn't it depend on there being space for the whole table in cache?
Post #1364122
Posted Tuesday, September 25, 2012 9:22 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:38 PM
Points: 6,637, Visits: 14,220
laurie-789651 (9/25/2012)
Perry Whittle (9/25/2012)
SQLSACT (9/25/2012)
Hi all

I have a quick question regarding pages moving from disk into memory

If I select * from a table, are all pages that make up the table and indexes moved into memory?

So any subsequent query against that same table would not need to go to disk at all?

Thanks

for select * there is no index and yes, all data pages would be cached into memory


Doesn't it depend on there being space for the whole table in cache?

yes of course, otherwise spill will happen


-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1364126
Posted Tuesday, September 25, 2012 10:21 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 2:08 AM
Points: 1,380, Visits: 2,703
Perry Whittle (9/25/2012)
laurie-789651 (9/25/2012)
Perry Whittle (9/25/2012)
SQLSACT (9/25/2012)
Hi all

I have a quick question regarding pages moving from disk into memory

If I select * from a table, are all pages that make up the table and indexes moved into memory?

So any subsequent query against that same table would not need to go to disk at all?

Thanks

for select * there is no index and yes, all data pages would be cached into memory


Doesn't it depend on there being space for the whole table in cache?

yes of course, otherwise spill will happen


Thanks

Spill?
Post #1364167
Posted Tuesday, September 25, 2012 12:19 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:38 PM
Points: 6,637, Visits: 14,220
to TempDB

-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1364230
Posted Tuesday, September 25, 2012 11:47 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 2:08 AM
Points: 1,380, Visits: 2,703
Perry Whittle (9/25/2012)
to TempDB


Thanks

So if a query is submitted to SQL and the pages need to be brought into memory from disk and there is not enough memory to accomodate those pages, SQL pushes is into tempdb, right?

Does is just push the pages that wouldn't fit in memory into tempdb or does it fulfill the entire transactions pages?

Is this where memory pressure in SQL server comes from?

Thanks
Post #1364442
Posted Wednesday, September 26, 2012 1:16 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 1:13 PM
Points: 40,428, Visits: 36,879
Perry Whittle (9/25/2012)
to TempDB


The buffer pool never spills to TempDB.

If pages are read in from disk for a table and there's not space in the buffer pool, other pages will be removed from it, maybe even pages of the same table that have already been read by the query processor.

What spills to tempDB are sorts, hashes, exchanges, spools (though they're temp structures anyway, so they can't exactly be said to spool).
Temp tables will be written to TempDB if necessary



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1364470
Posted Wednesday, September 26, 2012 1:21 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 1:13 PM
Points: 40,428, Visits: 36,879
SQLSACT (9/25/2012)
So if a query is submitted to SQL and the pages need to be brought into memory from disk and there is not enough memory to accomodate those pages, SQL pushes is into tempdb, right?


No. If pages are needed in memory and there's not enough space in the buffer pool, other data pages will be removed from the buffer pool to make space. The algorithm that is used to determine which pages to evict is roughly an LRU-2, but there are complexities and cases where pages can be removed from cache immediately after they are read in and used.

It is entirely possible, for a scan of a large table on a server with little memory, for the pages of that table to be read in, the rows on those pages processed by the query processor and then those pages removed from memory to make space for more pages from the same table.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1364474
Posted Wednesday, September 26, 2012 2:01 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:38 PM
Points: 6,637, Visits: 14,220
thanks I stand corrected

-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1364493
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse