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.
Author |
Topic |
MorrisK
Yak Posting Veteran
83 Posts |
Posted - 2008-07-28 : 18:18:10
|
I often need to query certain tables that contain datetime columns. These datetime columns are not included in any index. The tables are used by our third-party ERP sytem and I'm not sure it would be a good idea to add my own index. I'm wondering what would be the best approach for improving query performance.For example, one table is basically a list of job operations (There are many more columns than the ones I'm listing, these are just for example. Underscores are just to make it readable.) Job and operation make up the key.Job__Operation__PlannedStart__PlannedEnd__ActualStart__ActualEnd100__1__________7/1/08________7/2/08______7/2/08_______7/2/08100__2__________7/2/08________7/3/08______7/2/08_______NULL101__1__________7/1/08________7/1/08______7/1/08_______7/1/08101__2__________7/1/08________7/2/08______7/1/08_______7/2/08101__3__________7/2/08________7/2/08______7/2/08_______NULLDifferent queries are need for reports of -*operations planned to start on a particular date*operations planned to end on a particular date*operations actually started on a particular date*operations actually finished on a particular dateThe only option I can think of is to make my own tables that are indexed by date and that are updated periodically by a scheduled job. Then join those to the main tables in my queries. For example - OperationsPlannedToStartDate___Job__Operation7/1/08_100__17/1/08_101__17/1/08_101__2OperationsActualCompleteDate___Job__Operation7/1/08_101__17/2/08_100__17/2/08_101__2...and so on.Does anyone else have a suggestion?Thanks,Kevin |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-07-29 : 04:57:04
|
Sugestions...1) Find out if you can index those columns / what impact on other queries that would have. I think this is the best approach.2) data duplication is generally a bad idea. Dealing with synchronisation is a pain in the ass3) [This is probably inapplicable if your database is hosted by a third party] Is there legacy data that you seldom need to search in these tables. Is it possible to set a cut-off point (records over 5 years old or whatever) and hive old records off to another partition / table-------------Charlie |
|
|
MorrisK
Yak Posting Veteran
83 Posts |
Posted - 2008-07-29 : 15:01:15
|
Thanks for the advice. I'll look into adding indexes and archiving.Kevin |
|
|
|
|
|