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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Design Question to improve performance

Author  Topic 

souLTower
Starting Member

39 Posts

Posted - 2009-05-07 : 11:11:33
Thanks for taking the time.

I've inherited an invoicing application. Tons of data. One particular table generally runs about 700,000 records. This data has a one to many relationship with another huge table (about 1,000,000) records.

The first structure looks like this:

TABLE_Parent
ID, percentApplied,


TABLE_Child1
ID, parentID, foreignID


TABLE_Child2
ID, parentID, differentForeignID




The parent table will always have a child record in one child table, never in both. This causes any queries which need all of the pertinent data for the parent table to do a left join to both child tables. This combined with the usual join to the other big tables makes my queries, even with indexing, come in at 5 - 8 seconds depending on the amount of data to be returned. This is a production application and is widely used. I've decided that a performance improvement would be to de-normalize the tables (I actually don't think they should have been normalized in the first place) by adding 2 columns to look like this:


TABLE_Parent
ID, percentApplied, Child_1foreignID, Child_2differentForeignID



I will then add triggers to the 2 child tables to update the parent table on insert/update. With this strategy I can begin to improve performance in a targeted manner, addressing the worst performers to no longer use the left joins. Improvements will be able to be implemented through multiple production releases.

Thoughts?
Flames?

Thanks
ST



God Bless

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-07 : 11:19:48
As you told us there is a one:many relation between parent and child.
Looks like you cannot put the foreignId in the parent...

What is the ForeignId used for - I think there are more relations...

What's about merging Child1 and Child2 in ONE table?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

souLTower
Starting Member

39 Posts

Posted - 2009-05-07 : 12:06:33
I'm sorry. I wasn't clear. There is a one to one relationship between parent and either child. If there is a parent record there will be a single associated record in either child one or child 2. Since the application is in production it would be very difficult to modify the table structures to remove or combine the child tables. There are many reports and functions tied to the current design. My intention is to implement that change slowly by first changing the parent table to contain all the necessary data, then point processes to the new design in multiple phases, then drop the old design.

God Bless
Go to Top of Page
   

- Advertisement -