Showing posts with label folks. Show all posts
Showing posts with label folks. Show all posts

Thursday, March 22, 2012

Database File size monitor

What are folks using to monitor database file sizes? I have been tasked
with writing a script to monitor our db's (Yes I know there are growth
controls, etc...). I was hoping there maybe a way to keep track of this via
some widget dashboard, etc... I have Solarwinds and will look at importing
SAN mibs, but still would like to hear thoughts from others.
--
Paul Bergson
MVP - Directory Services
MCT, MCSE, MCSA, Security+, BS CSci
2003, 2000 (Early Achiever), NT
http://www.pbbergs.com
Please no e-mails, any questions should be posted in the NewsGroup
This posting is provided "AS IS" with no warranties, and confers no rights.Take a look at sp_helpdb. It'll show you how the db sizes are calculated.
Instead of just displaying the values, store then in a table and then you'll
be able to see how fast you db is growing each day, month, minute, hour...or
whatever.
--
MG
"Paul Bergson [MVP-DS]" wrote:
> What are folks using to monitor database file sizes? I have been tasked
> with writing a script to monitor our db's (Yes I know there are growth
> controls, etc...). I was hoping there maybe a way to keep track of this via
> some widget dashboard, etc... I have Solarwinds and will look at importing
> SAN mibs, but still would like to hear thoughts from others.
> --
> Paul Bergson
> MVP - Directory Services
> MCT, MCSE, MCSA, Security+, BS CSci
> 2003, 2000 (Early Achiever), NT
> http://www.pbbergs.com
> Please no e-mails, any questions should be posted in the NewsGroup
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>|||DECLARE @.DB sysname
DECLARE @.SQL nvarchar(255)
if exists ( select * from tempdb..sysobjects where name LIKE
'#FileStats__%' ) drop table #FileStats
CREATE TABLE #FileStats(
[FileId] INT,
[FileGroup] INT,
[TotalExtents] INT,
[UsedExtents] INT,
[Name] sysname,
[Filename] varchar(255)
)
DECLARE @.FileStats TABLE (
[FileId] INT,
[FileGroup] INT,
[TotalExtents] INT,
[UsedExtents] INT,
[Name] sysname,
[Filename] varchar(255)
)
DECLARE cDatabases CURSOR FOR
SELECT QUOTENAME(sdb.name)
FROM master.dbo.sysdatabases sdb
WHERE status & 32 != 32
AND status & 64 != 64
AND status & 128 != 128
AND status & 256 != 256
AND status & 512 != 512
AND status & 1024 != 1024
AND status & 4096 != 4096
AND status & 32768 !=32768
OPEN cDatabases
FETCH FROM cDatabases INTO @.DB
WHILE (@.@.FETCH_STATUS = 0)
BEGIN
DELETE FROM #FileStats
SET @.SQL = 'USE ' + @.DB + '; INSERT INTO #FileStats EXEC (''DBCC
SHOWFILESTATS'')'
EXEC (@.SQL)
UPDATE #FileStats SET name = @.DB
INSERT INTO @.FileStats SELECT * FROM #FileStats
FETCH FROM cDatabases INTO @.DB
END
CLOSE cDatabases
DEALLOCATE cDatabases
SELECT
[Name]
,[TotalExtents]*64/1024. AS TotalExtInMB
,[UsedExtents]*64/1024. AS UsedExtInMB
,([TotalExtents] - [UsedExtents]) / 16. AS UnAllocExtInMB --* 64 /
1024. AS UnAllocExtInMB
,CAST(FLOOR(ROUND([UsedExtents] * 100. / [TotalExtents], 0)) AS
VARCHAR(3)) + '%' AS Pct_Full
FROM @.FileStats
ORDER BY TotalExtInMB DESC
--exec sp_spaceused
DBCC sqlperf(logspace)
"Paul Bergson [MVP-DS]" <pbergson@.allete_nospam.com> wrote in message
news:uxH3fPY8HHA.2004@.TK2MSFTNGP06.phx.gbl...
> What are folks using to monitor database file sizes? I have been tasked
> with writing a script to monitor our db's (Yes I know there are growth
> controls, etc...). I was hoping there maybe a way to keep track of this
> via some widget dashboard, etc... I have Solarwinds and will look at
> importing SAN mibs, but still would like to hear thoughts from others.
> --
> Paul Bergson
> MVP - Directory Services
> MCT, MCSE, MCSA, Security+, BS CSci
> 2003, 2000 (Early Achiever), NT
> http://www.pbbergs.com
> Please no e-mails, any questions should be posted in the NewsGroup
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>|||I use a custom script based around aggregating data from DBCC SHOWFILESTATS.
--
Geoff N. Hiten
Senior SQL Infrastructure Consultant
Microsoft SQL Server MVP
"Paul Bergson [MVP-DS]" <pbergson@.allete_nospam.com> wrote in message
news:uxH3fPY8HHA.2004@.TK2MSFTNGP06.phx.gbl...
> What are folks using to monitor database file sizes? I have been tasked
> with writing a script to monitor our db's (Yes I know there are growth
> controls, etc...). I was hoping there maybe a way to keep track of this
> via some widget dashboard, etc... I have Solarwinds and will look at
> importing SAN mibs, but still would like to hear thoughts from others.
> --
> Paul Bergson
> MVP - Directory Services
> MCT, MCSE, MCSA, Security+, BS CSci
> 2003, 2000 (Early Achiever), NT
> http://www.pbbergs.com
> Please no e-mails, any questions should be posted in the NewsGroup
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>|||Thanks for your feedback, it is appreciated.
--
Paul Bergson
MVP - Directory Services
MCT, MCSE, MCSA, Security+, BS CSci
2003, 2000 (Early Achiever), NT
http://www.pbbergs.com
Please no e-mails, any questions should be posted in the NewsGroup
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hurme" <michael.geles@.thomson.com> wrote in message
news:F8CA1619-B919-45B9-9C76-75DF14160A66@.microsoft.com...
> Take a look at sp_helpdb. It'll show you how the db sizes are calculated.
> Instead of just displaying the values, store then in a table and then
> you'll
> be able to see how fast you db is growing each day, month, minute,
> hour...or
> whatever.
> --
> MG
>
> "Paul Bergson [MVP-DS]" wrote:
>> What are folks using to monitor database file sizes? I have been tasked
>> with writing a script to monitor our db's (Yes I know there are growth
>> controls, etc...). I was hoping there maybe a way to keep track of this
>> via
>> some widget dashboard, etc... I have Solarwinds and will look at
>> importing
>> SAN mibs, but still would like to hear thoughts from others.
>> --
>> Paul Bergson
>> MVP - Directory Services
>> MCT, MCSE, MCSA, Security+, BS CSci
>> 2003, 2000 (Early Achiever), NT
>> http://www.pbbergs.com
>> Please no e-mails, any questions should be posted in the NewsGroup
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>|||Thanks for your feedback, it is appreciated.
--
Paul Bergson
MVP - Directory Services
MCT, MCSE, MCSA, Security+, BS CSci
2003, 2000 (Early Achiever), NT
http://www.pbbergs.com
Please no e-mails, any questions should be posted in the NewsGroup
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jay" <nospam@.nospam.org> wrote in message
news:uUlhoBZ8HHA.5012@.TK2MSFTNGP02.phx.gbl...
> DECLARE @.DB sysname
> DECLARE @.SQL nvarchar(255)
> if exists ( select * from tempdb..sysobjects where name LIKE
> '#FileStats__%' ) drop table #FileStats
> CREATE TABLE #FileStats(
> [FileId] INT,
> [FileGroup] INT,
> [TotalExtents] INT,
> [UsedExtents] INT,
> [Name] sysname,
> [Filename] varchar(255)
> )
> DECLARE @.FileStats TABLE (
> [FileId] INT,
> [FileGroup] INT,
> [TotalExtents] INT,
> [UsedExtents] INT,
> [Name] sysname,
> [Filename] varchar(255)
> )
> DECLARE cDatabases CURSOR FOR
> SELECT QUOTENAME(sdb.name)
> FROM master.dbo.sysdatabases sdb
> WHERE status & 32 != 32
> AND status & 64 != 64
> AND status & 128 != 128
> AND status & 256 != 256
> AND status & 512 != 512
> AND status & 1024 != 1024
> AND status & 4096 != 4096
> AND status & 32768 !=32768
> OPEN cDatabases
> FETCH FROM cDatabases INTO @.DB
> WHILE (@.@.FETCH_STATUS = 0)
> BEGIN
> DELETE FROM #FileStats
> SET @.SQL = 'USE ' + @.DB + '; INSERT INTO #FileStats EXEC (''DBCC
> SHOWFILESTATS'')'
> EXEC (@.SQL)
> UPDATE #FileStats SET name = @.DB
> INSERT INTO @.FileStats SELECT * FROM #FileStats
> FETCH FROM cDatabases INTO @.DB
> END
> CLOSE cDatabases
> DEALLOCATE cDatabases
> SELECT
> [Name]
> ,[TotalExtents]*64/1024. AS TotalExtInMB
> ,[UsedExtents]*64/1024. AS UsedExtInMB
> ,([TotalExtents] - [UsedExtents]) / 16. AS UnAllocExtInMB --* 64 /
> 1024. AS UnAllocExtInMB
> ,CAST(FLOOR(ROUND([UsedExtents] * 100. / [TotalExtents], 0)) AS
> VARCHAR(3)) + '%' AS Pct_Full
> FROM @.FileStats
> ORDER BY TotalExtInMB DESC
> --exec sp_spaceused
> DBCC sqlperf(logspace)
> "Paul Bergson [MVP-DS]" <pbergson@.allete_nospam.com> wrote in message
> news:uxH3fPY8HHA.2004@.TK2MSFTNGP06.phx.gbl...
>> What are folks using to monitor database file sizes? I have been tasked
>> with writing a script to monitor our db's (Yes I know there are growth
>> controls, etc...). I was hoping there maybe a way to keep track of this
>> via some widget dashboard, etc... I have Solarwinds and will look at
>> importing SAN mibs, but still would like to hear thoughts from others.
>> --
>> Paul Bergson
>> MVP - Directory Services
>> MCT, MCSE, MCSA, Security+, BS CSci
>> 2003, 2000 (Early Achiever), NT
>> http://www.pbbergs.com
>> Please no e-mails, any questions should be posted in the NewsGroup
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>|||Thanks for your feedback, it is appreciated.
--
Paul Bergson
MVP - Directory Services
MCT, MCSE, MCSA, Security+, BS CSci
2003, 2000 (Early Achiever), NT
http://www.pbbergs.com
Please no e-mails, any questions should be posted in the NewsGroup
This posting is provided "AS IS" with no warranties, and confers no rights.
"Geoff N. Hiten" <SQLCraftsman@.gmail.com> wrote in message
news:ON2b3EZ8HHA.5752@.TK2MSFTNGP04.phx.gbl...
>I use a custom script based around aggregating data from DBCC
>SHOWFILESTATS.
> --
> Geoff N. Hiten
> Senior SQL Infrastructure Consultant
> Microsoft SQL Server MVP
>
> "Paul Bergson [MVP-DS]" <pbergson@.allete_nospam.com> wrote in message
> news:uxH3fPY8HHA.2004@.TK2MSFTNGP06.phx.gbl...
>> What are folks using to monitor database file sizes? I have been tasked
>> with writing a script to monitor our db's (Yes I know there are growth
>> controls, etc...). I was hoping there maybe a way to keep track of this
>> via some widget dashboard, etc... I have Solarwinds and will look at
>> importing SAN mibs, but still would like to hear thoughts from others.
>> --
>> Paul Bergson
>> MVP - Directory Services
>> MCT, MCSE, MCSA, Security+, BS CSci
>> 2003, 2000 (Early Achiever), NT
>> http://www.pbbergs.com
>> Please no e-mails, any questions should be posted in the NewsGroup
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>

Friday, February 24, 2012

Database design issue

Hello folks,

We are developing a datamart to which data comes from different sources (SQL, Sybase, Excel, MDB). There is going to be a refresh process that will do the retrieval.
In the source tables, there are columns that can be nullable.
In the destinaton tables, we are planning to convert all nullable to NOT Null, so that the indexing can be applied and the retrieval will be faster.

But then what default value can we give it for data types Varchar, Numeric and Date.

Is it fine to give Spaces(1) for Varchar and zero for numneric. What do we give for date?

If anyone can give an insight into these questions, i really appreciate it.

Thank you,
VenugopalYou can give '' for the varchar.

Be very careful though as you will be losing information as there will now be no difference between a null and empty string or null and zero numeric. These differences may be meaningful in the source which will now be lost.|||You can index a column that allows NULL values. Only the primary key is not allowed to take NULL values.

blindman|||In the destinaton tables, we are planning to convert all nullable to NOT Null, so that the indexing can be applied and the retrieval will be faster.


Eh?

Columns that contain NULLs can certainly be indexed; they just can't be a primary key. There is no speed issue involved.

The database schema must reflect the requirements of your data. If the original data can contain NULL values, then the repository database must do so also. There is no value whatsoever that you can substitute for "the absence of any value," which is what NULL is.|||And it can't be a unique index...DB2 has an option that allows it, but It doesn'r seems so with SQL Server...unless I'm missing it (WHAT? AGAIN?)

USE Northwind
GO

CREATE TABLE myTable99 (Col1 int, col2 char(10))
GO

CREATE INDEX myIndex1 ON myTable99 (Col1)
GO

INSERT INTO myTable99(Col1, Col2)
SELECT 1, 'A' UNION ALL
SELECT 2, 'B' UNION ALL
SELECT Null, 'C' UNION ALL
SELECT Null, 'D'

SELECT * FROM myTable99
GO

CREATE UNIQUE INDEX myIndex2 ON myTable99 (Col2)
GO

INSERT INTO myTable99(Col1, Col2)
SELECT 1, 'E' UNION ALL
SELECT 2, 'F' UNION ALL
SELECT Null, Null
GO

SELECT * FROM myTable99
GO

INSERT INTO myTable99(Col1, Col2)
SELECT 3, Null
GO

DROP TABLE myTable99
GO

Database Design Books

Hi folks,
Could some one suggest good Database Design books from
basic to InDepth . I have one from Wrox "Professional SQL
Server 2000 Database Design".
Thanks for the Help
ChipChip,
> Could some one suggest good Database Design books from
> basic to InDepth . I have one from Wrox "Professional SQL
> Server 2000 Database Design".
Database Design for Mere Mortals
Michael J. Hernandez
Addison Wesley, 1997
ISBN 0-201-69471-9
Data Modeling Essentials, 2nd Edition
Graeme C. Simsion
The Coriolis Group, 2001
ISBN 1-57610-872-4
Information Modeling and Relational Databases
Terry Halpin
Morgan Kaufmann, 2001
ISBN 1-55860-672-6
The Data Model Resource Book, Volume I
A Library of Universal Data Models for All Enterprises
Len Siverston
John Wiley & Sons, 2001
ISBN 0-471-38023-7
The Data Model Resource Book, Volume II
A Library of Universal Data Models by Industry Types
Len Siverston
John Wiley & Sons, 2001
ISBN 0-471-35348-5
Some online resources:
http://www.utexas.edu/its/windows/database/datamodeling/dm/design.html
http://www.cs.sfu.ca/CC/354/zaiane/material/notes/Chapter7/node1.html
http://www.palslib.com/Fundamentals/Database_Design.html
http://www.martinfowler.com/articles/evodb.html
Linda|||Hi Linda,
Thank you very much for the books list and for pointing me
to some good resources.
Best Regards
Chip
>--Original Message--
>Chip,
>> Could some one suggest good Database Design books from
>> basic to InDepth . I have one from Wrox "Professional
SQL
>> Server 2000 Database Design".
>Database Design for Mere Mortals
>Michael J. Hernandez
>Addison Wesley, 1997
>ISBN 0-201-69471-9
>Data Modeling Essentials, 2nd Edition
>Graeme C. Simsion
>The Coriolis Group, 2001
>ISBN 1-57610-872-4
>Information Modeling and Relational Databases
>Terry Halpin
>Morgan Kaufmann, 2001
>ISBN 1-55860-672-6
>The Data Model Resource Book, Volume I
>A Library of Universal Data Models for All Enterprises
>Len Siverston
>John Wiley & Sons, 2001
>ISBN 0-471-38023-7
>The Data Model Resource Book, Volume II
>A Library of Universal Data Models by Industry Types
>Len Siverston
>John Wiley & Sons, 2001
>ISBN 0-471-35348-5
>
>Some online resources:
>http://www.utexas.edu/its/windows/database/datamodeling/dm
/design.html
>http://www.cs.sfu.ca/CC/354/zaiane/material/notes/Chapter7
/node1.html
>http://www.palslib.com/Fundamentals/Database_Design.html
>http://www.martinfowler.com/articles/evodb.html
>
>Linda
>
>.
>

Database Design Books

Hi folks,
Could some one suggest good Database Design books from
basic to InDepth . I have one from Wrox "Professional SQL
Server 2000 Database Design".
Thanks for the Help
ChipChip,

> Could some one suggest good Database Design books from
> basic to InDepth . I have one from Wrox "Professional SQL
> Server 2000 Database Design".
Database Design for Mere Mortals
Michael J. Hernandez
Addison Wesley, 1997
ISBN 0-201-69471-9
Data Modeling Essentials, 2nd Edition
Graeme C. Simsion
The Coriolis Group, 2001
ISBN 1-57610-872-4
Information Modeling and Relational Databases
Terry Halpin
Morgan Kaufmann, 2001
ISBN 1-55860-672-6
The Data Model Resource Book, Volume I
A Library of Universal Data Models for All Enterprises
Len Siverston
John Wiley & Sons, 2001
ISBN 0-471-38023-7
The Data Model Resource Book, Volume II
A Library of Universal Data Models by Industry Types
Len Siverston
John Wiley & Sons, 2001
ISBN 0-471-35348-5
Some online resources:
http://www.utexas.edu/its/windows/d.../dm/design.html
http://www.cs.sfu.ca/CC/354/zaiane/...ter7/node1.html
http://www.palslib.com/Fundamentals...ase_Design.html
http://www.martinfowler.com/articles/evodb.html
Linda|||Hi Linda,
Thank you very much for the books list and for pointing me
to some good resources.
Best Regards
Chip
>--Original Message--
>Chip,
>
SQL
>Database Design for Mere Mortals
>Michael J. Hernandez
>Addison Wesley, 1997
>ISBN 0-201-69471-9
>Data Modeling Essentials, 2nd Edition
>Graeme C. Simsion
>The Coriolis Group, 2001
>ISBN 1-57610-872-4
>Information Modeling and Relational Databases
>Terry Halpin
>Morgan Kaufmann, 2001
>ISBN 1-55860-672-6
>The Data Model Resource Book, Volume I
>A Library of Universal Data Models for All Enterprises
>Len Siverston
>John Wiley & Sons, 2001
>ISBN 0-471-38023-7
>The Data Model Resource Book, Volume II
>A Library of Universal Data Models by Industry Types
>Len Siverston
>John Wiley & Sons, 2001
>ISBN 0-471-35348-5
>
>Some online resources:
>http://www.utexas.edu/its/windows/d...datamodeling/dm
/design.html
>http://www.cs.sfu.ca/CC/354/zaiane/.../notes/Chapter7
/node1.html
>http://www.palslib.com/Fundamentals...ase_Design.html
>http://www.martinfowler.com/articles/evodb.html
>
>Linda
>
>.
>