November 20, 2017 at 7:09 pm
SQL-DBA-01 - Friday, November 17, 2017 1:02 PMHiIs there any reason why the below DBid order is maintained?
Master - 1
TempDB - 2
Model - 3
MSDB - 4
Heck apparently its even different in Azure, go figure!
November 20, 2017 at 7:44 pm
patrickmcginnis59 10839 - Monday, November 20, 2017 3:26 PMJeff Moden - Sunday, November 19, 2017 12:20 PMSQL-DBA-01 - Sunday, November 19, 2017 11:34 AMEirikur Eiriksson - Sunday, November 19, 2017 11:05 AMJeff Moden - Sunday, November 19, 2017 9:42 AMSQL-DBA-01 - Friday, November 17, 2017 1:29 PMZZartin - Friday, November 17, 2017 1:17 PMWhy not?Do you know the sequence is like this?
It's an interesting question that you ask, especially since the startup order is Master, Resource, Model, TempDB, and MSDB. My question is, why is it important to you?
Trying to comprehend the reason and the goal of this question, like questioning north south east and west, kilos and punds etc.
😎If you can't make anything out of it, then the best option is to ignore it. 🙂
That's a poor attitude. Why do you want to know this? Curiosity goes both ways here.
I know that I would have asked a similar question when I started out with computer systems. Heck, for that matter, would it be important that these numbers stay constant for each installation during reboots? For any installation? For any version? Sure, we can only guess as we aren't the server implementers, but it turns out that often integer ID's like that need to be consistent throughout a code base but that their order could be completely arbitrary, that it is enough that master be 1 and other databases NOT be 1, and in that code base, when we asked for database 1, it be the same database as the other time we asked for database 1. Or maybe its important that 1 actually be master?
Maybe that's the case here, maybe its not. I know that during one project of mine, I needed to create about 20 or 30 opcodes, but that internally I could not constantly use character strings to reference these opcodes but rather I assigned integers to them in sequence and the value of these integers were completely arbitrary but once they were assigned they needed to stay that way throughout the codebase. Even though I then would have to keep using these integers, I could still refer (and generate references) to these integers by using something like named constants, similar to #define's with the c macro processor for instance and while I did refer to them, they got changed to integers and the program itself did not have to use character strings to find an occurence of a data structure, a constant integer index was just fine.
Personally, I doubt SQL-DBA-01's question was life or death or even important enough to merit this conglomeration of threadizens, but as a fan of forum psychology I do get interested in what triggers these "gang ups". So tell me, what offended you guys this time? Can you determine where SQL-DBA-01 went wrong? Or was his offense more imaginary in nature? Curious minds wanna know!
Very early in this thread Jeff answered "It's an interesting question that you ask, especially since the startup order is Master, Resource, Model, TempDB, and MSDB. My question is, why is it important to you?" to which OP replied "Jeff, I was eager to know why for tempDB it is 2 and why not it is 4. Jsut out of curiosity. If there is any reason in terms of architecture as concern. But anyways, seeing your answer looks like you never shown any interest to explore further on this. Hence I would not ask you any counter question. Thanks for replying to my question though. I feel pleased."
I think this is where SQL-DBA-01 started to go wrong.
November 20, 2017 at 8:23 pm
adish - Monday, November 20, 2017 7:44 PMpatrickmcginnis59 10839 - Monday, November 20, 2017 3:26 PMJeff Moden - Sunday, November 19, 2017 12:20 PMSQL-DBA-01 - Sunday, November 19, 2017 11:34 AMEirikur Eiriksson - Sunday, November 19, 2017 11:05 AMJeff Moden - Sunday, November 19, 2017 9:42 AMSQL-DBA-01 - Friday, November 17, 2017 1:29 PMZZartin - Friday, November 17, 2017 1:17 PMWhy not?Do you know the sequence is like this?
It's an interesting question that you ask, especially since the startup order is Master, Resource, Model, TempDB, and MSDB. My question is, why is it important to you?
Trying to comprehend the reason and the goal of this question, like questioning north south east and west, kilos and punds etc.
😎If you can't make anything out of it, then the best option is to ignore it. 🙂
That's a poor attitude. Why do you want to know this? Curiosity goes both ways here.
I know that I would have asked a similar question when I started out with computer systems. Heck, for that matter, would it be important that these numbers stay constant for each installation during reboots? For any installation? For any version? Sure, we can only guess as we aren't the server implementers, but it turns out that often integer ID's like that need to be consistent throughout a code base but that their order could be completely arbitrary, that it is enough that master be 1 and other databases NOT be 1, and in that code base, when we asked for database 1, it be the same database as the other time we asked for database 1. Or maybe its important that 1 actually be master?
Maybe that's the case here, maybe its not. I know that during one project of mine, I needed to create about 20 or 30 opcodes, but that internally I could not constantly use character strings to reference these opcodes but rather I assigned integers to them in sequence and the value of these integers were completely arbitrary but once they were assigned they needed to stay that way throughout the codebase. Even though I then would have to keep using these integers, I could still refer (and generate references) to these integers by using something like named constants, similar to #define's with the c macro processor for instance and while I did refer to them, they got changed to integers and the program itself did not have to use character strings to find an occurence of a data structure, a constant integer index was just fine.
Personally, I doubt SQL-DBA-01's question was life or death or even important enough to merit this conglomeration of threadizens, but as a fan of forum psychology I do get interested in what triggers these "gang ups". So tell me, what offended you guys this time? Can you determine where SQL-DBA-01 went wrong? Or was his offense more imaginary in nature? Curious minds wanna know!
Very early in this thread Jeff answered "It's an interesting question that you ask, especially since the startup order is Master, Resource, Model, TempDB, and MSDB. My question is, why is it important to you?" to which OP replied "Jeff, I was eager to know why for tempDB it is 2 and why not it is 4. Jsut out of curiosity. If there is any reason in terms of architecture as concern. But anyways, seeing your answer looks like you never shown any interest to explore further on this. Hence I would not ask you any counter question. Thanks for replying to my question though. I feel pleased."
I think this is where SQL-DBA-01 started to go wrong.
I think it was pretty straightforward tone wise, if a bit syntactically unfamiliar. I can understand however that the question itself is unusual, and maybe I can't be 100 percent positive about his tone, that's why I'd refrain from judging either way but I get your point.
November 20, 2017 at 8:34 pm
Just in case anyone is interested in the side bar of which order the databases are loaded in, here's a list of the database loads on the last startup of my laptop. Entries chronologically start ascending from the bottom.
The order for that box is master, mssqlsystemresource, model, and then msdb. A bunch of user databases are loaded, then TempDB (the highlighted line) and then more user databases. That's a 2008 Developer's Edition.
On my prod box, which is the 2016 Enterprise edition, they look like this (kept the same bottom up order so as not to confuse and didn't print all the interceding database names).
... bunch of user databases here...
...bunch of user databases here...
From the looks of it, master started and then just about everything else started up at the same second mark including all the system databases except TempDB and that started last but only 3 seconds later.
So my guess is that the numbering they used was as I said... they were numbered according to the order of their development rather than anything having to do with startup order or anything else that may be logical with the possible exception of the master database. I was actually a bit surprised on both machines to see master load before the mssqlsystemresource database but I'll leave that to someone that knows the internals.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 20, 2017 at 10:03 pm
Jeff Moden - Monday, November 20, 2017 8:34 PMJust in case anyone is interested in the side bar of which order the databases are loaded in, here's a list of the database loads on the last startup of my laptop. Entries chronologically start ascending from the bottom.The order for that box is master, mssqlsystemresource, model, and then msdb. A bunch of user databases are loaded, then TempDB (the highlighted line) and then more user databases. That's a 2008 Developer's Edition.
On my prod box, which is the 2016 Enterprise edition, they look like this (kept the same bottom up order so as not to confuse and didn't print all the interceding database names).
... bunch of user databases here...
...bunch of user databases here...From the looks of it, master started and then just about everything else started up at the same second mark including all the system databases except TempDB and that started last but only 3 seconds later.
So my guess is that the numbering they used was as I said... they were numbered according to the order of their development rather than anything having to do with startup order or anything else that may be logical with the possible exception of the master database. I was actually a bit surprised on both machines to see master load before the mssqlsystemresource database but I'll leave that to someone that knows the internals.
The load order is far less interesting than the actual database names... "BlackArts01" & "NastyFast01..."
It's kinda like using the Kama Sutra to demonstrate how the Dewey Decimal System works, to a 15 year old...
November 20, 2017 at 11:38 pm
Jason A. Long - Monday, November 20, 2017 10:03 PMThe load order is far less interesting than the actual database names... "BlackArts01" & "NastyFast01..."
It's kinda like using the Kama Sutra to demonstrate how the Dewey Decimal System works, to a 15 year old...
You'd like the BlackArts01 and NastyFast01 databases. They contain the guts of databases used in presentations to demonstrate some really fast code. One of them, for example, demonstrates a 5 aggregate system across 7 million row (1040 bytes per row) of a 7GB table and uses one of the aggregates as a divisor for the others to produce 4 different temporal percentage aggregates by month for 7 years with 4 other columns ranking by month, month of year, year, and grand total... in about 4 seconds. Part of the ancillary learning in that presentation is how to truly use minimal logging to create the table with the clustered index already in place and it clearly demonstrates why you shouldn't necessarily delete "duplicate" indexes. It also demonstrates the fallacy of relying on a Clustered Index for performance especially on wide tables.
BlackArts01 was the precon that Ed Wagner and I did for Pittsburgh back in 2016 and featured parts of NastyFast01. It's also where I pointed out the extreme importance of the number "318" to every DBA in the world. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
November 20, 2017 at 11:53 pm
Jeff Moden - Monday, November 20, 2017 8:34 PMFrom the looks of it, master started and then just about everything else started up at the same second mark including all the system databases except TempDB and that started last but only 3 seconds later.
Once master is started, multiple threads are spawned and the DBs are started up in parallel, assuming a normal startup
I don't know why I'm bothering to add more here though.
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
November 21, 2017 at 2:07 am
Jason A. Long - Monday, November 20, 2017 10:03 PMJeff Moden - Monday, November 20, 2017 8:34 PMJust in case anyone is interested in the side bar of which order the databases are loaded in, here's a list of the database loads on the last startup of my laptop. Entries chronologically start ascending from the bottom.The order for that box is master, mssqlsystemresource, model, and then msdb. A bunch of user databases are loaded, then TempDB (the highlighted line) and then more user databases. That's a 2008 Developer's Edition.
On my prod box, which is the 2016 Enterprise edition, they look like this (kept the same bottom up order so as not to confuse and didn't print all the interceding database names).
... bunch of user databases here...
...bunch of user databases here...From the looks of it, master started and then just about everything else started up at the same second mark including all the system databases except TempDB and that started last but only 3 seconds later.
So my guess is that the numbering they used was as I said... they were numbered according to the order of their development rather than anything having to do with startup order or anything else that may be logical with the possible exception of the master database. I was actually a bit surprised on both machines to see master load before the mssqlsystemresource database but I'll leave that to someone that knows the internals.
The load order is far less interesting than the actual database names... "BlackArts01" & "NastyFast01..."
It's kinda like using the Kama Sutra to demonstrate how the Dewey Decimal System works, to a 15 year old...
But more interesting than that is what the B is for in JBM :crazy:
Far away is close at hand in the images of elsewhere.
Anon.
November 21, 2017 at 7:46 am
Like I said earlier, the id assignment of system databases simply results from the order in which the database are created during installation. It has nothing to do with startup. TEMPDB gets recreated at startup, but SQL Server reuses the same database_id of 2. The id of SSISDB, which isn't really a system database, can vary depending on when SSIS was installed, which could be after the user databases are created.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
November 21, 2017 at 8:13 am
GilaMonster - Monday, November 20, 2017 11:53 PMJeff Moden - Monday, November 20, 2017 8:34 PMFrom the looks of it, master started and then just about everything else started up at the same second mark including all the system databases except TempDB and that started last but only 3 seconds later.
Once master is started, multiple threads are spawned and the DBs are started up in parallel, assuming a normal startup
I don't know why I'm bothering to add more here though.
Understood on that. And apologies a bit.... You said that TempDb starts up just before Model and I missed the part where you were able to prove it. with something. I'd really be interested in seeing that because it seems contrary to the fact that if you have something you've added in the Model database (a Tally Table, for example), it will automatically appear in TempDb after a restart. I think the only way that could happen is if Model did fully start before TempDB.... either that or they copy to TempDB after they're both started and I think the wouldn't do it that way.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 21, 2017 at 8:29 am
Jeff Moden - Tuesday, November 21, 2017 8:13 AMGilaMonster - Monday, November 20, 2017 11:53 PMJeff Moden - Monday, November 20, 2017 8:34 PMFrom the looks of it, master started and then just about everything else started up at the same second mark including all the system databases except TempDB and that started last but only 3 seconds later.
Once master is started, multiple threads are spawned and the DBs are started up in parallel, assuming a normal startup
I don't know why I'm bothering to add more here though.Understood on that. And apologies a bit.... You said that TempDb starts up just before Model and I missed the part where you were able to prove it. with something. I'd really be interested in seeing that because it seems contrary to the fact that if you have something you've added in the Model database (a Tally Table, for example), it will automatically appear in TempDb after a restart. I think the only way that could happen is if Model did fully start before TempDB.... either that or they copy to TempDB after they're both started and I think the wouldn't do it that way.
tempdb is re-created every time SQL Server is started so that the system always starts with a clean copy of the database. Temporary tables and stored procedures are dropped automatically on disconnect, and no connections are active when the system is shut down. Therefore, there is never anything in tempdb to be saved from one session of SQL Server to another. Backup and restore operations are not allowed on tempdb.
https://docs.microsoft.com/en-us/sql/relational-databases/databases/tempdb-database
Also since tempdb has an id of 2 (right????) this contradicts the assertion that id's are assigned in the order that databases are created.
November 21, 2017 at 8:37 am
Jeff Moden - Monday, November 20, 2017 11:38 PMJason A. Long - Monday, November 20, 2017 10:03 PMThe load order is far less interesting than the actual database names... "BlackArts01" & "NastyFast01..."
It's kinda like using the Kama Sutra to demonstrate how the Dewey Decimal System works, to a 15 year old...You'd like the BlackArts01 and NastyFast01 databases. They contain the guts of databases used in presentations to demonstrate some really fast code. One of them, for example, demonstrates a 5 aggregate system across 7 million row (1040 bytes per row) of a 7GB table and uses one of the aggregates as a divisor for the others to produce 4 different temporal percentage aggregates by month for 7 years with 4 other columns ranking by month, month of year, year, and grand total... in about 4 seconds. Part of the ancillary learning in that presentation is how to truly use minimal logging to create the table with the clustered index already in place and it clearly demonstrates why you shouldn't necessarily delete "duplicate" indexes. It also demonstrates the fallacy of relying on a Clustered Index for performance especially on wide tables.
BlackArts01 was the precon that Ed Wagner and I did for Pittsburgh back in 2016 and featured parts of NastyFast01. It's also where I pointed out the extreme importance of the number "318" to every DBA in the world. 😉
You should bring that to SQLSaturday #700, Jeff.
November 21, 2017 at 8:58 am
patrickmcginnis59 10839 - Tuesday, November 21, 2017 8:29 AMJeff Moden - Tuesday, November 21, 2017 8:13 AMGilaMonster - Monday, November 20, 2017 11:53 PMJeff Moden - Monday, November 20, 2017 8:34 PMFrom the looks of it, master started and then just about everything else started up at the same second mark including all the system databases except TempDB and that started last but only 3 seconds later.
Once master is started, multiple threads are spawned and the DBs are started up in parallel, assuming a normal startup
I don't know why I'm bothering to add more here though.Understood on that. And apologies a bit.... You said that TempDb starts up just before Model and I missed the part where you were able to prove it. with something. I'd really be interested in seeing that because it seems contrary to the fact that if you have something you've added in the Model database (a Tally Table, for example), it will automatically appear in TempDb after a restart. I think the only way that could happen is if Model did fully start before TempDB.... either that or they copy to TempDB after they're both started and I think the wouldn't do it that way.
tempdb is re-created every time SQL Server is started so that the system always starts with a clean copy of the database. Temporary tables and stored procedures are dropped automatically on disconnect, and no connections are active when the system is shut down. Therefore, there is never anything in tempdb to be saved from one session of SQL Server to another. Backup and restore operations are not allowed on tempdb.
https://docs.microsoft.com/en-us/sql/relational-databases/databases/tempdb-database
Also since tempdb has an id of 2 (right????) this contradicts the assertion that id's are assigned in the order that databases are created.
Actually, I don't think it occurs on startup as much as on shutdown.
I just shutdown my SQL Server 2014 DE on my laptop and the datetime on the files after shutdown were at shutdown time.
November 21, 2017 at 9:12 am
Lynn Pettis - Tuesday, November 21, 2017 8:58 AMpatrickmcginnis59 10839 - Tuesday, November 21, 2017 8:29 AMJeff Moden - Tuesday, November 21, 2017 8:13 AMGilaMonster - Monday, November 20, 2017 11:53 PMJeff Moden - Monday, November 20, 2017 8:34 PMFrom the looks of it, master started and then just about everything else started up at the same second mark including all the system databases except TempDB and that started last but only 3 seconds later.
Once master is started, multiple threads are spawned and the DBs are started up in parallel, assuming a normal startup
I don't know why I'm bothering to add more here though.Understood on that. And apologies a bit.... You said that TempDb starts up just before Model and I missed the part where you were able to prove it. with something. I'd really be interested in seeing that because it seems contrary to the fact that if you have something you've added in the Model database (a Tally Table, for example), it will automatically appear in TempDb after a restart. I think the only way that could happen is if Model did fully start before TempDB.... either that or they copy to TempDB after they're both started and I think the wouldn't do it that way.
tempdb is re-created every time SQL Server is started so that the system always starts with a clean copy of the database. Temporary tables and stored procedures are dropped automatically on disconnect, and no connections are active when the system is shut down. Therefore, there is never anything in tempdb to be saved from one session of SQL Server to another. Backup and restore operations are not allowed on tempdb.
https://docs.microsoft.com/en-us/sql/relational-databases/databases/tempdb-database
Also since tempdb has an id of 2 (right????) this contradicts the assertion that id's are assigned in the order that databases are created.
Actually, I don't think it occurs on startup as much as on shutdown.
I just shutdown my SQL Server 2014 DE on my laptop and the datetime on the files after shutdown were at shutdown time.
Hmm.... is that the last modified date or the created date though 🙂
November 21, 2017 at 9:49 am
patrickmcginnis59 10839 - Tuesday, November 21, 2017 8:29 AMtempdb is re-created every time SQL Server is started so that the system always starts with a clean copy of the database. Temporary tables and stored procedures are dropped automatically on disconnect, and no connections are active when the system is shut down. Therefore, there is never anything in tempdb to be saved from one session of SQL Server to another. Backup and restore operations are not allowed on tempdb.
https://docs.microsoft.com/en-us/sql/relational-databases/databases/tempdb-database
Also since tempdb has an id of 2 (right????) this contradicts the assertion that id's are assigned in the order that databases are created.
This is from a 2014 instance that was installed last year and has been re-started a few times. Looking at SYS.DATABASES, it's unclear in what order databases are initially created (or attached). However, MASTER would have to be initialized first, because it's responsible for keeping track of database_id for all other databases. I'm thinking it's .mdf file is probably distributed with installation media and attached due to the odd create_date. MODEL has the same create_date as MASTER. The create_date of MSDB seems to correlate with version of MSSQL; on a 2016 instance I see it's 2016-04-30 even though it was installed earlier in 2017.
The create_date on TEMPDB correlates to the last time the instance was re-started and gets updated every time. I'm thinking that TEMPDB would have to be created before MSDB, because SQL Server does some T-SQL configuration stuff, like setting up SQL Agent, that would require TEMPDB already in place.
SELECT name, create_date, database_id
FROM sys.databases
WHERE database_id <= 4
ORDER BY create_date, database_id;
name create_date database_id
master 2003-04-08 09:13:36.390 1
model 2003-04-08 09:13:36.390 3
msdb 2014-02-20 20:49:38.857 4
tempdb 2017-10-21 19:53:30.710 2
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
Viewing 15 posts - 46 through 60 (of 90 total)
You must be logged in to reply to this topic. Login to reply