BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Performance problems in MSSQL

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Anders Balslev
Guest





PostPosted: Mon Oct 30, 2006 9:11 am    Post subject: Performance problems in MSSQL Reply with quote



Hi

BDS2006
WinXP
MSSQL 2005

Can anyone give me a hint?

I run an application connected to a MSSQL database.

Table1:
(Table1ID int IDENTITY(1,1),
Field2 ..,
Field3..,
MyDateTimeField datetime,
Field4..
..
.. )
Table1ID is the primary index (non-clustered)
MyDateTimeField is a secondary index (clustered)


Table2:
(Table2ID int IDENTITY(1,1),
Field2...,
Field3...,
Table1ID int)
Table2ID is the primary index (non-clustered)
Table1ID is the primary index (clustered)


Table1 and Table 2 are related in a Master-Detail relation

Both tables contains a "Lot of rows" (>100000)

In my DataModule I have
ADODataset1 (connected to Table1 by means of "SELECT * FROM Table1 WHERE
MyDateTimeField BETWEEN :DateFrom AND :DateTo"
- Opening this dataset shouldn't be a problem, limiting the dates

ADODataset2 (Connected to Table2 by means of "SELECT * FROM Table2") - and
here the problem comes.

I have ADODataset2-->MasterSource, pointing to a datasource, which points on
Table1, specifying the link field = Table1ID

These are agan concerted to ClientDatasets, where Clientdataset1 thereby
have a DatasetField

By analyzing the the SQL profiler-->Trace, I can see that table2 are opened
with ALL rows, not only the rows that are related to Table1.

Are there any parameters on the table components that I can set in order to
ask the compiler ONLY to return the detail rows that are relevant?

Best regards
Anders Balslev
Back to top
Oliver Townshend
Guest





PostPosted: Mon Oct 30, 2006 4:28 pm    Post subject: Re: Performance problems in MSSQL Reply with quote



Quote:
Are there any parameters on the table components that I can set in order
to
ask the compiler ONLY to return the detail rows that are relevant?

Make your SQL:

select *
from table2
where table1id=:Table1ID

and the mastersource will populate the parameters and you'll be in business.

Oliver Townshend
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.