Internals of data insertion into the table

  • Hi,

    When we insert the data into a table, what happened exactly(process)?

    How the data will be inserted? For any modifications sql server uses t-log right? How the t-log will be committed to data pages?

    Thanks,

    🙂

  • The transaction log is used for all modifications to guarantee atomicity, durability and consistency. Read Gail's thorough article.

    http://www.sqlservercentral.com/articles/Administration/64582/

  • The transaction log records aren't committed to data pages. The data modification is made to the data pages (in memory) and then logged into the transaction log. The only time you get replay from the log is in database recovery or restores (or on the mirror DB in database mirroring).

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    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
  • GilaMonster (9/25/2012)


    The transaction log records aren't committed to data pages. The data modification is made to the data pages (in memory) and then logged into the transaction log. The only time you get replay from the log is in database recovery or restores (or on the mirror DB in database mirroring).

    The data modification is made to the data pages (in memory) and then logged into the transaction log.

    That means

    1. Sql server fetches the table related data pages to memory (What is the memory in this case is it RAM?)

    Q. How many pages will be fetched to Memory?

    Q2. How does server knows that the pages are related to a table?

    if i am wrong can u correct me, Can you tell me the process of insertion?

    Thanks alot

    🙂

  • There are scads and scads of processes that take place when you insert data. I'd suggest getting a copy of Kalen Delaney's book SQL Server Internals. That covers the process in wonderful detail much better than you're going to get in a simple forum post.

    May I ask, what specifically are you trying to understand about it? Are you hitting some type of problem?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • SQL* (9/25/2012)


    Q. How many pages will be fetched to Memory?

    As many as are needed for the query

    Q2. How does server knows that the pages are related to a table?

    In short, the allocation pages (or which there are many kinds) and the system tables.

    Read Kalen's book, read Paul Randal's blog.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    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

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply