Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 empty tables or columns effecting database perform

Author  Topic 

remraks
Starting Member

6 Posts

Posted - 2009-08-14 : 04:56:06
Hi All,

I am new to this group and quite new to databases as such we got a
database in office which have lot of unused empty tables and empty
rows which have accumulated over the years. I am trying to improve the
performance of the system I was wondering whether this would affect
the performance of the system in anyway.

We are talking about 150 empty tables in a database which has 250
tables :)
your opinions will be much appreciated

Regards
Rem

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-14 : 10:17:38
probably not affecting performance. but if you're 100% certain they aren't needed, drop 'em
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-08-14 : 11:12:34
what do you mean by "empty rows"?





Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

dataswirl
Starting Member

6 Posts

Posted - 2009-08-16 : 15:23:53
Arent rows dropped if empty?

Is there anyway to tell if a table has been or is in use? would you check the t-log for that kind of thing?
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-16 : 16:01:36
quote:
Originally posted by dataswirl

Arent rows dropped if empty?

Is there anyway to tell if a table has been or is in use? would you check the t-log for that kind of thing?



Pages are deallocated. Rows are of an arbitrary size and are meaningless in this context.
Go to Top of Page

remraks
Starting Member

6 Posts

Posted - 2009-08-19 : 03:39:03
quote:
Originally posted by russell

quote:
Originally posted by dataswirl

Arent rows dropped if empty?

Is there anyway to tell if a table has been or is in use? would you check the t-log for that kind of thing?



Pages are deallocated. Rows are of an arbitrary size and are meaningless in this context.




quote:
Originally posted by russell

probably not affecting performance. but if you're 100% certain they aren't needed, drop 'em



Thanks a lot Russell couple of questions more

How long does the server keep alive a deadlocked transaction. Is there any way to kill all those transactions by running a command.

Our server at times eats up a lot of ram and throws the out of memory message to the application is there anyway to get around this other than to restart the service. I think its mainly coz of bad programming that this issue props up.
Go to Top of Page

remraks
Starting Member

6 Posts

Posted - 2009-08-19 : 03:39:43
quote:
Originally posted by Transact Charlie

what do you mean by "empty rows"?





Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION





what I meant was rows with null values not empty
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-08-19 : 04:55:07
So you've got rows where every value for each column is NULL?

Yes -- they will damage your performance. Such rows contain no useful information but still take up space and still need to be scanned if you undergo an index scan.

They should be easy to find and remove though.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

remraks
Starting Member

6 Posts

Posted - 2009-08-19 : 05:13:42
quote:
Originally posted by Transact Charlie

So you've got rows where every value for each column is NULL?

Yes -- they will damage your performance. Such rows contain no useful information but still take up space and still need to be scanned if you undergo an index scan.

They should be easy to find and remove though.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION





Thanks Charlie,Yeah they are easy but got to go through a lot of tables.
You got any tips for my second query regarding freeing up memory. Our SQL server eats up a lot of memory at times and throws the out of memory error.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-08-19 : 05:28:31
Well I'm a little troubled that your data schema allows a table to have all null rows in the first place. Knowing that, I wouldn't be surprised if your database might be a bit of a mess.

It's impossible for us to say what could be eating your memory without knowing more about he kind of queries that you are running, your table structure (including keys, indexes, what the specification on your sql server is like, etc, etc.

Do you know if your database obeys any particular level of normalisation?

Is there a particular query or type of query that often runs into problems?

Do you have a lot of long running transactions?




Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

remraks
Starting Member

6 Posts

Posted - 2009-08-19 : 05:35:44
quote:
Originally posted by Transact Charlie

Well I'm a little troubled that your data schema allows a table to have all null rows in the first place. Knowing that, I wouldn't be surprised if your database might be a bit of a mess.

It's impossible for us to say what could be eating your memory without knowing more about he kind of queries that you are running, your table structure (including keys, indexes, what the specification on your sql server is like, etc, etc.

Do you know if your database obeys any particular level of normalisation?

Is there a particular query or type of query that often runs into problems?

Do you have a lot of long running transactions?




Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION





You are absolutely right that our database is in a royal mess its like many novice programmers and db developers have messes it up over a period of 8yrs now and they dont work our company now since I was doing windows admin thought would try and clear up the mess and filth that has accumulated over the years.

Do you know any query or sp which I can run to get the worst performing query or do you know of any process by which I can try and find them.

We do have some long running transactions especially when our reporting team runs reports in them
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-08-19 : 06:11:13
Use this to start with -- customise the order by clause to narrow in on the stats you want to look at.

SELECT TOP 50
creation_time
, last_execution_time
, total_physical_reads
, total_logical_reads
, total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
, SUBSTRING(
st.text
, (qs.statement_start_offset/2) + 1

, (
(
CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset
END
- qs.statement_start_offset
)
/2
)
+ 1) AS statement_text

FROM
sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
ORDER BY
total_elapsed_time / execution_count DESC;

-- this works on 2005, don't know about 2000. What version of sql server are you using?

The best tool would be to run SQL Profiler on the database / server for a while. It's got a performance enhancement suggestion mode..... You mileage my vary however.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-08-19 : 06:14:18
Also -- a good first step would be to have a look at the table structure.

Do all your tables have primary keys / clustered indexes? If a table doesn't have a clustered index it is a heap table and that should generally be avoided.

You can only have 1 clustered index on a table (this is how the data if physically stored) a good CI will make all the difference in the world to your query speeds.

Index strategy is heavily dependant on the types of queries you are going to be running. Consider indexes on a case by case basis.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

remraks
Starting Member

6 Posts

Posted - 2009-08-19 : 06:24:20
Charlie thanks a lot for that I would run that one during peak hours and let you know the result

I am using SQL 2005

All the tables does have Pk need to check further regarding the indexing part.
Go to Top of Page
   

- Advertisement -