Showing posts with label linked. Show all posts
Showing posts with label linked. Show all posts

Tuesday, March 20, 2012

performance problem with linked sybase tables

We have a need to retrieve Sybase data within a MS SQL Server
application. We are using SQL Server's linked database feature with
the Sybase 12.0 OLE DB driver. It takes 5 minutes to run a query that
takes 2 seconds from isql.

Any suggestions?

ThanksLarryboy (dean.roberts@.sscgp.com) writes:
> We have a need to retrieve Sybase data within a MS SQL Server
> application. We are using SQL Server's linked database feature with
> the Sybase 12.0 OLE DB driver. It takes 5 minutes to run a query that
> takes 2 seconds from isql.

I guess you need to do some analysis to see whether it's
a network problem, or whether it could be that the query gets a different
query plan when it comes in on the linked server. If running sp_who
on the Sybase machine through the linked server is fast, then we can
rule out network.

I don't know about Sybase, but on MS SQL Server you can different
query plans depending on the SET options. I don't know if Sybase
has DBCC USEROPTIONS, but if it has, you can run this both in ISQL
and through the linked server, to see if there are any differences.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Performance problem while using Linked Servers

I am transferring data from SQl Server 2000 to Oracle through Linked
Servers.It takes considerable amount of time while transferring data
from SQL Server to oracle.Both these databases are at remote
locations.I am executing a Stored procedure on SQL Server and what it
does is,It has an Insert statement which reads the data from a table in
SQL Server and inserts it into the Oracle table. It is a very time
consuming process.Vice-Versa it takes very less time for Oracle-SQL
Server transfer.If anybody has a clue towards reducing the time in SQL
Server-ORACLE transfer.How about extracting the data, sending the file and then inserting at
the other end ? i.e. dump to csv then import from csv. Not sure about
the Oracle side, but doing this from SQL is straight forward enough.

Ryan

Raja wrote:
> I am transferring data from SQl Server 2000 to Oracle through Linked
> Servers.It takes considerable amount of time while transferring data
> from SQL Server to oracle.Both these databases are at remote
> locations.I am executing a Stored procedure on SQL Server and what it
> does is,It has an Insert statement which reads the data from a table
in
> SQL Server and inserts it into the Oracle table. It is a very time
> consuming process.Vice-Versa it takes very less time for Oracle-SQL
> Server transfer.If anybody has a clue towards reducing the time in
SQL
> Server-ORACLE transfer.|||Thanks,Ryan
Yes,but the entire process has to be automated.At present I have an
Interface where in the records selected are transferred through the
execution of a Stored procedure.As suggested by you,we can also
transfer the data in the form of an XML through Webservice.For some
reasons WebService is not used,hence the only option is Linked Server.
Dumping the data into a File(CSV or XML) and inserting the same
into Oracle isnt a problem.Do you have any suggestions for sending the
file?.

Regards,
Raja|||How about using a DTS package to extract the data into a CSV and then
saving / moving this file onto the other server ? You can script moving
the file to wherever you need, or saving it there in the first place.
You'll need to understand how to script this, but it should be
reasonably straight forward. The bit I don't know is the Oracle end for
importing it once you have the file. As you are extracting the data and
then importing it anyway, this might be quicker than copying directly
as you are doing.

So, your DTS package would contain a connection to your database, a SQL
task for running your SP linked to a Text File (source) for your CSV
(selects everything from the SP into this file), and a VB ActiveX
script to move the file to the new server.....Then do whatever you
need to do on the Oracle side. OK, so it's split the task into a
process for SQL and a process for Oracle and doesn't automate the
'entire' process, so hopefully someone can suggest a better way.

Ryan

Wednesday, March 7, 2012

Performance of query joining tables linked between different datab

The following query takes almost two minutes to run:
SELECT Reference.dbo.tlkpInstruments.IDInstrument,
Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
FROM dbo.tblAccounts LEFT OUTER JOIN
Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =
Reference.dbo.tlkpInstruments.IDInstrument
tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
All rows retrieved in less than 5 seconds.
tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
All rows retrieved in less than 5 seconds.
Why is the query running so slowly?
Thanks.
The linked column in the subsidiary table is the primary key of that table
and is indexed that way. In the main table, I've tried indexing the linked
column separately and adding it to the primary key. Neither approach makes
any substantial change.
I've also tried importing the subsidiary table into the main database. There
is no change to the performance.
Anything else I can try?
"Tibor Karaszi" wrote:

> Start by adding indexes on the columns that you do the join over. Also consider making one or even
> both of the indexes clustered indexes (assuming that is suitable).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "TLD" <TLD@.discussions.microsoft.com> wrote in message
> news:5FF860E0-152C-4C5C-AB90-1FA78D9E05B1@.microsoft.com...
>
|||99% chance it's the way you've indexed the tables.
Post the DDL (CREATE TABLE and CREATE INDEX statements) and someone can
probably help.
-Dave
TLD wrote:[vbcol=seagreen]
> The linked column in the subsidiary table is the primary key of that table
> and is indexed that way. In the main table, I've tried indexing the linked
> column separately and adding it to the primary key. Neither approach makes
> any substantial change.
> I've also tried importing the subsidiary table into the main database. There
> is no change to the performance.
> Anything else I can try?
> "Tibor Karaszi" wrote:
-Dave Markle
http://www.markleconsulting.com/blog
|||TLD, I don't see a thing wrong with your query from a performance
perspective.
Try this:
SELECT
i.IDInstrument,
i.Instrument,
a.*
into #bleh
FROM dbo.tblAccounts a
LEFT JOIN dbo.tlkpInstruments i
ON a.Commodities = i.IDInstrument;
DROP TABLE #bleh;
How long does that take? If it's quick, it probably indicates that you
have a problem with the speed of returning rows to the client. This can
be caused by a network configuration issue or by having some task on the
client side that's eating up CPU cycles.
What happens when you put this in front of your query? What are the
results in your "Messages" window?
SET STATISTICS IO ON;
-Dave
TLD wrote:[vbcol=seagreen]
> Here are table and index definitions:
>
> CREATE TABLE [dbo].[tblAccounts] (
> [AccID] [bigint] NOT NULL ,
> [OffID] [int] NOT NULL ,
> [ID] [bigint] NULL ,
> [AccNo] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [AccName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Office] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Level] [tinyint] NULL ,
> [3rdPartyGty] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Division] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [USRating] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [UKRating] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [InitReqmnts] [int] NULL ,
> [StressExposure] [int] NULL ,
> [MarDefExcess] [int] NULL ,
> [ARTL] [int] NULL ,
> [SRTL] [int] NULL ,
> [IMTL] [int] NULL ,
> [PCOvr] [tinyint] NULL ,
> [Action] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [EvalDate] [smalldatetime] NULL ,
> [RenewDate] [smalldatetime] NULL ,
> [LevelPrevious] [int] NULL ,
> [EvalDatePrevious] [smalldatetime] NULL ,
> [Note] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Exclude] [bit] NULL ,
> [NetLiquidity] [int] NULL ,
> [MaxRisk] [int] NULL ,
> [NotAmt] [int] NULL ,
> [MarReqd] [int] NULL ,
> [Country] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [SHEquity] [int] NULL ,
> [EstProfit] [int] NULL ,
> [Exposure] [numeric](10, 2) NULL ,
> [Options] [bit] NULL ,
> [Contracts] [int] NULL ,
> [Symbol] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [PriceCurrent] [money] NULL ,
> [PriceHistoric] [money] NULL ,
> [Documentation] [bit] NULL ,
> [Commodities] [int] NULL ,
> [Comment] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [MD] [bit] NULL ,
> [Diversified] [smallint] NULL ,
> [Doc] [smallint] NULL ,
> [Credit] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Legal] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Accepted] [smallint] NULL ,
> [Man] [bit] NULL ,
> [TriggerContracts] [int] NULL ,
> [Inst] [nvarchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
>
> CREATE UNIQUE CLUSTERED
> INDEX [PK_tblAccounts] ON [dbo].[tblAccounts] ([AccID], [OffID],
> [Commodities])
> WITH
> FILLFACTOR = 90
> ,DROP_EXISTING
> ON [PRIMARY]
> CREATE TABLE [dbo].[tlkpInstruments] (
> [IDInstrument] [int] IDENTITY (1, 1) NOT NULL ,
> [Instrument] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [ExchangeID] [int] NOT NULL ,
> [GroupID] [int] NULL ,
> [Collective] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
> CREATE UNIQUE CLUSTERED
> INDEX [PK_tlkpInstruments] ON [dbo].[tlkpInstruments] ([IDInstrument])
> WITH
> DROP_EXISTING
> ON [PRIMARY]
>
> "TLD" wrote:
-Dave Markle
http://www.markleconsulting.com/blog
|||This is a local instance of SServer. There is no network connection. The only
client running is Query Analyzer.
The SELECT... INTO took one second.
Re-running the query takes 1m54s:
Application Profile Statistics
Timer resolution (milliseconds)00
Number of INSERT, UPDATE, DELETE statements00
Rows effected by INSERT, UPDATE, DELETE statements00
Number of SELECT statements11
Rows effected by SELECT statements4334843348
Number of user transactions22
Average fetch time00
Cumulative fetch time00
Number of fetches00
Number of open statement handles00
Max number of opened statement handles00
Cumulative number of statement handles00
Network Statistics
Number of server roundtrips11
Number of TDS packets sent11
Number of TDS packets received27092709
Number of bytes sent644644
Number of bytes received1.10936e+0071.10936e+007
Time Statistics
Cumulative client processing time00
Cumulative wait time on server replies6464
"Dave Markle" <"dma[remove_ZZ]ZZrkle" wrote:

> TLD, I don't see a thing wrong with your query from a performance
> perspective.
> Try this:
> SELECT
> i.IDInstrument,
> i.Instrument,
> a.*
> into #bleh
> FROM dbo.tblAccounts a
> LEFT JOIN dbo.tlkpInstruments i
> ON a.Commodities = i.IDInstrument;
> DROP TABLE #bleh;
> How long does that take? If it's quick, it probably indicates that you
> have a problem with the speed of returning rows to the client. This can
> be caused by a network configuration issue or by having some task on the
> client side that's eating up CPU cycles.
> What happens when you put this in front of your query? What are the
> results in your "Messages" window?
> SET STATISTICS IO ON;
> -Dave
>
> TLD wrote:
>
> --
> -Dave Markle
> http://www.markleconsulting.com/blog
>
|||The two minutes is slow, of course,
But your "5 seconds" timings are suspect, too.
Are you running on a tiny, tiny machine, or on a busy server with just
all kinds of other stuff going on?
You ought to be able to fetch both tables and the join in five seconds
easy, even with no keys at all, on anything like a current machine.
J.
On Fri, 26 Jan 2007 09:38:01 -0800, TLD
<TLD@.discussions.microsoft.com> wrote:

>The following query takes almost two minutes to run:
>SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>FROM dbo.tblAccounts LEFT OUTER JOIN
> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =
>Reference.dbo.tlkpInstruments.IDInstrument
>tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>All rows retrieved in less than 5 seconds.
>tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
>All rows retrieved in less than 5 seconds.
>Why is the query running so slowly?
>Thanks.
|||I'm using a dual-Opteron 64 workstation with 2G of memory. SQL Server is
installed as a local instance. There is no active network connection.
"JXStern" wrote:

> The two minutes is slow, of course,
> But your "5 seconds" timings are suspect, too.
> Are you running on a tiny, tiny machine, or on a busy server with just
> all kinds of other stuff going on?
> You ought to be able to fetch both tables and the join in five seconds
> easy, even with no keys at all, on anything like a current machine.
> J.
>
> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
>
>
|||I should add that the performance is the same when running with an Access
front-end in a server environment. This is why I'm trying to get it
straightened out on a local machine first. The speed of return of the tables
by themselves is less than five seconds, more like three.
This shouldn't make any difference but there are many more records in the
main table without an associated record in the subsidiary than there are with
one. That brings up a lot of NULLs.
What about the order of the fields in the join? Could that make any
difference?
"JXStern" wrote:

> The two minutes is slow, of course,
> But your "5 seconds" timings are suspect, too.
> Are you running on a tiny, tiny machine, or on a busy server with just
> all kinds of other stuff going on?
> You ought to be able to fetch both tables and the join in five seconds
> easy, even with no keys at all, on anything like a current machine.
> J.
>
> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
>
>
|||Here is an answer:
The field which is causing the delay is
TriggerContracts int 4
When all except this field are accessed with the join, the return is less
than five seconds. When this field is included the return is two minutes.
Bracketing the name doesn't change the performance. Changing the name to
TContracts doesn't change the performance. Add the field to the clustered
index doesn't change the performance. What in the world is going on?
"JXStern" wrote:

> The two minutes is slow, of course,
> But your "5 seconds" timings are suspect, too.
> Are you running on a tiny, tiny machine, or on a busy server with just
> all kinds of other stuff going on?
> You ought to be able to fetch both tables and the join in five seconds
> easy, even with no keys at all, on anything like a current machine.
> J.
>
> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
>
>
|||The problem has been solved. By reworking my front end, I was able to
eliminate some of the fields in the query. Now it runs in less than five
seconds.
Thanks to all for your help.
"JXStern" wrote:

> The two minutes is slow, of course,
> But your "5 seconds" timings are suspect, too.
> Are you running on a tiny, tiny machine, or on a busy server with just
> all kinds of other stuff going on?
> You ought to be able to fetch both tables and the join in five seconds
> easy, even with no keys at all, on anything like a current machine.
> J.
>
> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
>
>

Performance of query joining tables linked between different datab

The following query takes almost two minutes to run:
SELECT Reference.dbo.tlkpInstruments.IDInstrument,
Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
FROM dbo.tblAccounts LEFT OUTER JOIN
Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities = Reference.dbo.tlkpInstruments.IDInstrument
tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
All rows retrieved in less than 5 seconds.
tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
All rows retrieved in less than 5 seconds.
Why is the query running so slowly?
Thanks.Start by adding indexes on the columns that you do the join over. Also consider making one or even
both of the indexes clustered indexes (assuming that is suitable).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"TLD" <TLD@.discussions.microsoft.com> wrote in message
news:5FF860E0-152C-4C5C-AB90-1FA78D9E05B1@.microsoft.com...
> The following query takes almost two minutes to run:
> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> FROM dbo.tblAccounts LEFT OUTER JOIN
> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => Reference.dbo.tlkpInstruments.IDInstrument
> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> All rows retrieved in less than 5 seconds.
> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> All rows retrieved in less than 5 seconds.
> Why is the query running so slowly?
> Thanks.|||The linked column in the subsidiary table is the primary key of that table
and is indexed that way. In the main table, I've tried indexing the linked
column separately and adding it to the primary key. Neither approach makes
any substantial change.
I've also tried importing the subsidiary table into the main database. There
is no change to the performance.
Anything else I can try?
"Tibor Karaszi" wrote:
> Start by adding indexes on the columns that you do the join over. Also consider making one or even
> both of the indexes clustered indexes (assuming that is suitable).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "TLD" <TLD@.discussions.microsoft.com> wrote in message
> news:5FF860E0-152C-4C5C-AB90-1FA78D9E05B1@.microsoft.com...
> > The following query takes almost two minutes to run:
> >
> > SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> > Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> > FROM dbo.tblAccounts LEFT OUTER JOIN
> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => > Reference.dbo.tlkpInstruments.IDInstrument
> >
> > tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> > All rows retrieved in less than 5 seconds.
> >
> > tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> > All rows retrieved in less than 5 seconds.
> >
> > Why is the query running so slowly?
> >
> > Thanks.
>|||Having the tables cross databases shouldn't affect performance (but cross instances would). Next
step would be considering what index that should be the clustered index.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"TLD" <TLD@.discussions.microsoft.com> wrote in message
news:A384955A-EB0A-43E1-B2DE-A03768D317E1@.microsoft.com...
> The linked column in the subsidiary table is the primary key of that table
> and is indexed that way. In the main table, I've tried indexing the linked
> column separately and adding it to the primary key. Neither approach makes
> any substantial change.
> I've also tried importing the subsidiary table into the main database. There
> is no change to the performance.
> Anything else I can try?
> "Tibor Karaszi" wrote:
>> Start by adding indexes on the columns that you do the join over. Also consider making one or
>> even
>> both of the indexes clustered indexes (assuming that is suitable).
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "TLD" <TLD@.discussions.microsoft.com> wrote in message
>> news:5FF860E0-152C-4C5C-AB90-1FA78D9E05B1@.microsoft.com...
>> > The following query takes almost two minutes to run:
>> >
>> > SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>> > Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>> > FROM dbo.tblAccounts LEFT OUTER JOIN
>> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =>> > Reference.dbo.tlkpInstruments.IDInstrument
>> >
>> > tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>> > All rows retrieved in less than 5 seconds.
>> >
>> > tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
>> > All rows retrieved in less than 5 seconds.
>> >
>> > Why is the query running so slowly?
>> >
>> > Thanks.
>>|||99% chance it's the way you've indexed the tables.
Post the DDL (CREATE TABLE and CREATE INDEX statements) and someone can
probably help.
-Dave
TLD wrote:
> The linked column in the subsidiary table is the primary key of that table
> and is indexed that way. In the main table, I've tried indexing the linked
> column separately and adding it to the primary key. Neither approach makes
> any substantial change.
> I've also tried importing the subsidiary table into the main database. There
> is no change to the performance.
> Anything else I can try?
> "Tibor Karaszi" wrote:
>> Start by adding indexes on the columns that you do the join over. Also consider making one or even
>> both of the indexes clustered indexes (assuming that is suitable).
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "TLD" <TLD@.discussions.microsoft.com> wrote in message
>> news:5FF860E0-152C-4C5C-AB90-1FA78D9E05B1@.microsoft.com...
>> The following query takes almost two minutes to run:
>> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>> FROM dbo.tblAccounts LEFT OUTER JOIN
>> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =>> Reference.dbo.tlkpInstruments.IDInstrument
>> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>> All rows retrieved in less than 5 seconds.
>> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
>> All rows retrieved in less than 5 seconds.
>> Why is the query running so slowly?
>> Thanks.
-Dave Markle
http://www.markleconsulting.com/blog|||Here are table and index definitions:
CREATE TABLE [dbo].[tblAccounts] (
[AccID] [bigint] NOT NULL ,
[OffID] [int] NOT NULL ,
[ID] [bigint] NULL ,
[AccNo] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AccName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Office] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Level] [tinyint] NULL ,
[3rdPartyGty] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Division] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[USRating] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[UKRating] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[InitReqmnts] [int] NULL ,
[StressExposure] [int] NULL ,
[MarDefExcess] [int] NULL ,
[ARTL] [int] NULL ,
[SRTL] [int] NULL ,
[IMTL] [int] NULL ,
[PCOvr] [tinyint] NULL ,
[Action] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[EvalDate] [smalldatetime] NULL ,
[RenewDate] [smalldatetime] NULL ,
[LevelPrevious] [int] NULL ,
[EvalDatePrevious] [smalldatetime] NULL ,
[Note] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Exclude] [bit] NULL ,
[NetLiquidity] [int] NULL ,
[MaxRisk] [int] NULL ,
[NotAmt] [int] NULL ,
[MarReqd] [int] NULL ,
[Country] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[SHEquity] [int] NULL ,
[EstProfit] [int] NULL ,
[Exposure] [numeric](10, 2) NULL ,
[Options] [bit] NULL ,
[Contracts] [int] NULL ,
[Symbol] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PriceCurrent] [money] NULL ,
[PriceHistoric] [money] NULL ,
[Documentation] [bit] NULL ,
[Commodities] [int] NULL ,
[Comment] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[MD] [bit] NULL ,
[Diversified] [smallint] NULL ,
[Doc] [smallint] NULL ,
[Credit] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Legal] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Accepted] [smallint] NULL ,
[Man] [bit] NULL ,
[TriggerContracts] [int] NULL ,
[Inst] [nvarchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
CREATE UNIQUE CLUSTERED
INDEX [PK_tblAccounts] ON [dbo].[tblAccounts] ([AccID], [OffID],
[Commodities])
WITH
FILLFACTOR = 90
,DROP_EXISTING
ON [PRIMARY]
CREATE TABLE [dbo].[tlkpInstruments] (
[IDInstrument] [int] IDENTITY (1, 1) NOT NULL ,
[Instrument] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ExchangeID] [int] NOT NULL ,
[GroupID] [int] NULL ,
[Collective] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
CREATE UNIQUE CLUSTERED
INDEX [PK_tlkpInstruments] ON [dbo].[tlkpInstruments] ([IDInstrument])
WITH
DROP_EXISTING
ON [PRIMARY]
"TLD" wrote:
> The following query takes almost two minutes to run:
> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> FROM dbo.tblAccounts LEFT OUTER JOIN
> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => Reference.dbo.tlkpInstruments.IDInstrument
> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> All rows retrieved in less than 5 seconds.
> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> All rows retrieved in less than 5 seconds.
> Why is the query running so slowly?
> Thanks.|||TLD, I don't see a thing wrong with your query from a performance
perspective.
Try this:
SELECT
i.IDInstrument,
i.Instrument,
a.*
into #bleh
FROM dbo.tblAccounts a
LEFT JOIN dbo.tlkpInstruments i
ON a.Commodities = i.IDInstrument;
DROP TABLE #bleh;
How long does that take? If it's quick, it probably indicates that you
have a problem with the speed of returning rows to the client. This can
be caused by a network configuration issue or by having some task on the
client side that's eating up CPU cycles.
What happens when you put this in front of your query? What are the
results in your "Messages" window?
SET STATISTICS IO ON;
-Dave
TLD wrote:
> Here are table and index definitions:
>
> CREATE TABLE [dbo].[tblAccounts] (
> [AccID] [bigint] NOT NULL ,
> [OffID] [int] NOT NULL ,
> [ID] [bigint] NULL ,
> [AccNo] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [AccName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Office] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Level] [tinyint] NULL ,
> [3rdPartyGty] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Division] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [USRating] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [UKRating] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [InitReqmnts] [int] NULL ,
> [StressExposure] [int] NULL ,
> [MarDefExcess] [int] NULL ,
> [ARTL] [int] NULL ,
> [SRTL] [int] NULL ,
> [IMTL] [int] NULL ,
> [PCOvr] [tinyint] NULL ,
> [Action] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [EvalDate] [smalldatetime] NULL ,
> [RenewDate] [smalldatetime] NULL ,
> [LevelPrevious] [int] NULL ,
> [EvalDatePrevious] [smalldatetime] NULL ,
> [Note] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Exclude] [bit] NULL ,
> [NetLiquidity] [int] NULL ,
> [MaxRisk] [int] NULL ,
> [NotAmt] [int] NULL ,
> [MarReqd] [int] NULL ,
> [Country] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [SHEquity] [int] NULL ,
> [EstProfit] [int] NULL ,
> [Exposure] [numeric](10, 2) NULL ,
> [Options] [bit] NULL ,
> [Contracts] [int] NULL ,
> [Symbol] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [PriceCurrent] [money] NULL ,
> [PriceHistoric] [money] NULL ,
> [Documentation] [bit] NULL ,
> [Commodities] [int] NULL ,
> [Comment] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [MD] [bit] NULL ,
> [Diversified] [smallint] NULL ,
> [Doc] [smallint] NULL ,
> [Credit] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Legal] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [Accepted] [smallint] NULL ,
> [Man] [bit] NULL ,
> [TriggerContracts] [int] NULL ,
> [Inst] [nvarchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
>
> CREATE UNIQUE CLUSTERED
> INDEX [PK_tblAccounts] ON [dbo].[tblAccounts] ([AccID], [OffID],
> [Commodities])
> WITH
> FILLFACTOR = 90
> ,DROP_EXISTING
> ON [PRIMARY]
> CREATE TABLE [dbo].[tlkpInstruments] (
> [IDInstrument] [int] IDENTITY (1, 1) NOT NULL ,
> [Instrument] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [ExchangeID] [int] NOT NULL ,
> [GroupID] [int] NULL ,
> [Collective] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
> CREATE UNIQUE CLUSTERED
> INDEX [PK_tlkpInstruments] ON [dbo].[tlkpInstruments] ([IDInstrument])
> WITH
> DROP_EXISTING
> ON [PRIMARY]
>
> "TLD" wrote:
>> The following query takes almost two minutes to run:
>> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>> FROM dbo.tblAccounts LEFT OUTER JOIN
>> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =>> Reference.dbo.tlkpInstruments.IDInstrument
>> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>> All rows retrieved in less than 5 seconds.
>> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
>> All rows retrieved in less than 5 seconds.
>> Why is the query running so slowly?
>> Thanks.
-Dave Markle
http://www.markleconsulting.com/blog|||This is a local instance of SServer. There is no network connection. The only
client running is Query Analyzer.
The SELECT... INTO took one second.
Re-running the query takes 1m54s:
Application Profile Statistics
Timer resolution (milliseconds) 0 0
Number of INSERT, UPDATE, DELETE statements 0 0
Rows effected by INSERT, UPDATE, DELETE statements 0 0
Number of SELECT statements 1 1
Rows effected by SELECT statements 43348 43348
Number of user transactions 2 2
Average fetch time 0 0
Cumulative fetch time 0 0
Number of fetches 0 0
Number of open statement handles 0 0
Max number of opened statement handles 0 0
Cumulative number of statement handles 0 0
Network Statistics
Number of server roundtrips 1 1
Number of TDS packets sent 1 1
Number of TDS packets received 2709 2709
Number of bytes sent 644 644
Number of bytes received 1.10936e+007 1.10936e+007
Time Statistics
Cumulative client processing time 0 0
Cumulative wait time on server replies 64 64
"Dave Markle" <"dma[remove_ZZ]ZZrkle" wrote:
> TLD, I don't see a thing wrong with your query from a performance
> perspective.
> Try this:
> SELECT
> i.IDInstrument,
> i.Instrument,
> a.*
> into #bleh
> FROM dbo.tblAccounts a
> LEFT JOIN dbo.tlkpInstruments i
> ON a.Commodities = i.IDInstrument;
> DROP TABLE #bleh;
> How long does that take? If it's quick, it probably indicates that you
> have a problem with the speed of returning rows to the client. This can
> be caused by a network configuration issue or by having some task on the
> client side that's eating up CPU cycles.
> What happens when you put this in front of your query? What are the
> results in your "Messages" window?
> SET STATISTICS IO ON;
> -Dave
>
> TLD wrote:
> > Here are table and index definitions:
> >
> >
> > CREATE TABLE [dbo].[tblAccounts] (
> > [AccID] [bigint] NOT NULL ,
> > [OffID] [int] NOT NULL ,
> > [ID] [bigint] NULL ,
> > [AccNo] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [AccName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [Office] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [Level] [tinyint] NULL ,
> > [3rdPartyGty] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [Division] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [USRating] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [UKRating] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [InitReqmnts] [int] NULL ,
> > [StressExposure] [int] NULL ,
> > [MarDefExcess] [int] NULL ,
> > [ARTL] [int] NULL ,
> > [SRTL] [int] NULL ,
> > [IMTL] [int] NULL ,
> > [PCOvr] [tinyint] NULL ,
> > [Action] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [EvalDate] [smalldatetime] NULL ,
> > [RenewDate] [smalldatetime] NULL ,
> > [LevelPrevious] [int] NULL ,
> > [EvalDatePrevious] [smalldatetime] NULL ,
> > [Note] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [Exclude] [bit] NULL ,
> > [NetLiquidity] [int] NULL ,
> > [MaxRisk] [int] NULL ,
> > [NotAmt] [int] NULL ,
> > [MarReqd] [int] NULL ,
> > [Country] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [SHEquity] [int] NULL ,
> > [EstProfit] [int] NULL ,
> > [Exposure] [numeric](10, 2) NULL ,
> > [Options] [bit] NULL ,
> > [Contracts] [int] NULL ,
> > [Symbol] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [PriceCurrent] [money] NULL ,
> > [PriceHistoric] [money] NULL ,
> > [Documentation] [bit] NULL ,
> > [Commodities] [int] NULL ,
> > [Comment] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [MD] [bit] NULL ,
> > [Diversified] [smallint] NULL ,
> > [Doc] [smallint] NULL ,
> > [Credit] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [Legal] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [Accepted] [smallint] NULL ,
> > [Man] [bit] NULL ,
> > [TriggerContracts] [int] NULL ,
> > [Inst] [nvarchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> > ) ON [PRIMARY]
> >
> >
> > CREATE UNIQUE CLUSTERED
> > INDEX [PK_tblAccounts] ON [dbo].[tblAccounts] ([AccID], [OffID],
> > [Commodities])
> > WITH
> > FILLFACTOR = 90
> > ,DROP_EXISTING
> > ON [PRIMARY]
> >
> > CREATE TABLE [dbo].[tlkpInstruments] (
> > [IDInstrument] [int] IDENTITY (1, 1) NOT NULL ,
> > [Instrument] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> > [Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> > [ExchangeID] [int] NOT NULL ,
> > [GroupID] [int] NULL ,
> > [Collective] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> > ) ON [PRIMARY]
> >
> > CREATE UNIQUE CLUSTERED
> > INDEX [PK_tlkpInstruments] ON [dbo].[tlkpInstruments] ([IDInstrument])
> > WITH
> > DROP_EXISTING
> > ON [PRIMARY]
> >
> >
> > "TLD" wrote:
> >
> >> The following query takes almost two minutes to run:
> >>
> >> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> >> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> >> FROM dbo.tblAccounts LEFT OUTER JOIN
> >> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => >> Reference.dbo.tlkpInstruments.IDInstrument
> >>
> >> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> >> All rows retrieved in less than 5 seconds.
> >>
> >> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> >> All rows retrieved in less than 5 seconds.
> >>
> >> Why is the query running so slowly?
> >>
> >> Thanks.
>
> --
> -Dave Markle
> http://www.markleconsulting.com/blog
>|||The two minutes is slow, of course,
But your "5 seconds" timings are suspect, too.
Are you running on a tiny, tiny machine, or on a busy server with just
all kinds of other stuff going on?
You ought to be able to fetch both tables and the join in five seconds
easy, even with no keys at all, on anything like a current machine.
J.
On Fri, 26 Jan 2007 09:38:01 -0800, TLD
<TLD@.discussions.microsoft.com> wrote:
>The following query takes almost two minutes to run:
>SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>FROM dbo.tblAccounts LEFT OUTER JOIN
> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =>Reference.dbo.tlkpInstruments.IDInstrument
>tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>All rows retrieved in less than 5 seconds.
>tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
>All rows retrieved in less than 5 seconds.
>Why is the query running so slowly?
>Thanks.|||I'm using a dual-Opteron 64 workstation with 2G of memory. SQL Server is
installed as a local instance. There is no active network connection.
"JXStern" wrote:
> The two minutes is slow, of course,
> But your "5 seconds" timings are suspect, too.
> Are you running on a tiny, tiny machine, or on a busy server with just
> all kinds of other stuff going on?
> You ought to be able to fetch both tables and the join in five seconds
> easy, even with no keys at all, on anything like a current machine.
> J.
>
> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
> >The following query takes almost two minutes to run:
> >
> >SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> >Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> >FROM dbo.tblAccounts LEFT OUTER JOIN
> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => >Reference.dbo.tlkpInstruments.IDInstrument
> >
> >tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> >All rows retrieved in less than 5 seconds.
> >
> >tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> >All rows retrieved in less than 5 seconds.
> >
> >Why is the query running so slowly?
> >
> >Thanks.
>|||I should add that the performance is the same when running with an Access
front-end in a server environment. This is why I'm trying to get it
straightened out on a local machine first. The speed of return of the tables
by themselves is less than five seconds, more like three.
This shouldn't make any difference but there are many more records in the
main table without an associated record in the subsidiary than there are with
one. That brings up a lot of NULLs.
What about the order of the fields in the join? Could that make any
difference?
"JXStern" wrote:
> The two minutes is slow, of course,
> But your "5 seconds" timings are suspect, too.
> Are you running on a tiny, tiny machine, or on a busy server with just
> all kinds of other stuff going on?
> You ought to be able to fetch both tables and the join in five seconds
> easy, even with no keys at all, on anything like a current machine.
> J.
>
> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
> >The following query takes almost two minutes to run:
> >
> >SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> >Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> >FROM dbo.tblAccounts LEFT OUTER JOIN
> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => >Reference.dbo.tlkpInstruments.IDInstrument
> >
> >tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> >All rows retrieved in less than 5 seconds.
> >
> >tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> >All rows retrieved in less than 5 seconds.
> >
> >Why is the query running so slowly?
> >
> >Thanks.
>|||Here is an answer:
The field which is causing the delay is
TriggerContracts int 4
When all except this field are accessed with the join, the return is less
than five seconds. When this field is included the return is two minutes.
Bracketing the name doesn't change the performance. Changing the name to
TContracts doesn't change the performance. Add the field to the clustered
index doesn't change the performance. What in the world is going on?
"JXStern" wrote:
> The two minutes is slow, of course,
> But your "5 seconds" timings are suspect, too.
> Are you running on a tiny, tiny machine, or on a busy server with just
> all kinds of other stuff going on?
> You ought to be able to fetch both tables and the join in five seconds
> easy, even with no keys at all, on anything like a current machine.
> J.
>
> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
> >The following query takes almost two minutes to run:
> >
> >SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> >Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> >FROM dbo.tblAccounts LEFT OUTER JOIN
> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => >Reference.dbo.tlkpInstruments.IDInstrument
> >
> >tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> >All rows retrieved in less than 5 seconds.
> >
> >tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> >All rows retrieved in less than 5 seconds.
> >
> >Why is the query running so slowly?
> >
> >Thanks.
>|||The problem has been solved. By reworking my front end, I was able to
eliminate some of the fields in the query. Now it runs in less than five
seconds.
Thanks to all for your help.
"JXStern" wrote:
> The two minutes is slow, of course,
> But your "5 seconds" timings are suspect, too.
> Are you running on a tiny, tiny machine, or on a busy server with just
> all kinds of other stuff going on?
> You ought to be able to fetch both tables and the join in five seconds
> easy, even with no keys at all, on anything like a current machine.
> J.
>
> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
> >The following query takes almost two minutes to run:
> >
> >SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> >Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> >FROM dbo.tblAccounts LEFT OUTER JOIN
> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => >Reference.dbo.tlkpInstruments.IDInstrument
> >
> >tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> >All rows retrieved in less than 5 seconds.
> >
> >tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> >All rows retrieved in less than 5 seconds.
> >
> >Why is the query running so slowly?
> >
> >Thanks.
>|||On Sun, 28 Jan 2007 08:46:00 -0800, TLD
<TLD@.discussions.microsoft.com> wrote:
>The problem has been solved. By reworking my front end, I was able to
>eliminate some of the fields in the query. Now it runs in less than five
>seconds.
Aha. Was that five seconds / two minutes to your app, or were those
timings from the query analyzer? I've seen situations where the front
end was busy and didn't accept the results for thirty seconds or more,
especially if all development is being done on a single system, was
that your situation?
Not to mention, a dual-64 with (only!) 2gb RAM, running SQLServer and
an open instance of VS, might be running short of memory - VS being an
unbelievable pig. Might run a lot faster on even a small server over
the network.
J.
>Thanks to all for your help.
>"JXStern" wrote:
>> The two minutes is slow, of course,
>> But your "5 seconds" timings are suspect, too.
>> Are you running on a tiny, tiny machine, or on a busy server with just
>> all kinds of other stuff going on?
>> You ought to be able to fetch both tables and the join in five seconds
>> easy, even with no keys at all, on anything like a current machine.
>> J.
>>
>> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
>> <TLD@.discussions.microsoft.com> wrote:
>> >The following query takes almost two minutes to run:
>> >
>> >SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>> >Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>> >FROM dbo.tblAccounts LEFT OUTER JOIN
>> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =>> >Reference.dbo.tlkpInstruments.IDInstrument
>> >
>> >tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>> >All rows retrieved in less than 5 seconds.
>> >
>> >tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
>> >All rows retrieved in less than 5 seconds.
>> >
>> >Why is the query running so slowly?
>> >
>> >Thanks.
>>|||That was from Query Analyzer (five seconds) on the local system. I also
tested on a network with the Access front end on a 2G Thinkpad (5400 rpm
disk) with 1G of memory. There it runs in just under 30 seconds, which is
equivalent to the opening of the main form.
Thanks for your help.
"JXStern" wrote:
> On Sun, 28 Jan 2007 08:46:00 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
> >The problem has been solved. By reworking my front end, I was able to
> >eliminate some of the fields in the query. Now it runs in less than five
> >seconds.
> Aha. Was that five seconds / two minutes to your app, or were those
> timings from the query analyzer? I've seen situations where the front
> end was busy and didn't accept the results for thirty seconds or more,
> especially if all development is being done on a single system, was
> that your situation?
> Not to mention, a dual-64 with (only!) 2gb RAM, running SQLServer and
> an open instance of VS, might be running short of memory - VS being an
> unbelievable pig. Might run a lot faster on even a small server over
> the network.
> J.
>
>
> >
> >Thanks to all for your help.
> >
> >"JXStern" wrote:
> >
> >> The two minutes is slow, of course,
> >>
> >> But your "5 seconds" timings are suspect, too.
> >>
> >> Are you running on a tiny, tiny machine, or on a busy server with just
> >> all kinds of other stuff going on?
> >>
> >> You ought to be able to fetch both tables and the join in five seconds
> >> easy, even with no keys at all, on anything like a current machine.
> >>
> >> J.
> >>
> >>
> >> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> >> <TLD@.discussions.microsoft.com> wrote:
> >>
> >> >The following query takes almost two minutes to run:
> >> >
> >> >SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> >> >Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> >> >FROM dbo.tblAccounts LEFT OUTER JOIN
> >> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => >> >Reference.dbo.tlkpInstruments.IDInstrument
> >> >
> >> >tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> >> >All rows retrieved in less than 5 seconds.
> >> >
> >> >tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> >> >All rows retrieved in less than 5 seconds.
> >> >
> >> >Why is the query running so slowly?
> >> >
> >> >Thanks.
> >>
> >>
>|||On Sun, 28 Jan 2007 10:28:01 -0800, TLD
<TLD@.discussions.microsoft.com> wrote:
>That was from Query Analyzer (five seconds) on the local system. I also
>tested on a network with the Access front end on a 2G Thinkpad (5400 rpm
>disk) with 1G of memory. There it runs in just under 30 seconds, which is
>equivalent to the opening of the main form.
>Thanks for your help.
So, was VS open on the "server"?
If I helped, you're welcome,
but I guess I'm still mystified.
J.
>
>"JXStern" wrote:
>> On Sun, 28 Jan 2007 08:46:00 -0800, TLD
>> <TLD@.discussions.microsoft.com> wrote:
>> >The problem has been solved. By reworking my front end, I was able to
>> >eliminate some of the fields in the query. Now it runs in less than five
>> >seconds.
>> Aha. Was that five seconds / two minutes to your app, or were those
>> timings from the query analyzer? I've seen situations where the front
>> end was busy and didn't accept the results for thirty seconds or more,
>> especially if all development is being done on a single system, was
>> that your situation?
>> Not to mention, a dual-64 with (only!) 2gb RAM, running SQLServer and
>> an open instance of VS, might be running short of memory - VS being an
>> unbelievable pig. Might run a lot faster on even a small server over
>> the network.
>> J.
>>
>>
>> >
>> >Thanks to all for your help.
>> >
>> >"JXStern" wrote:
>> >
>> >> The two minutes is slow, of course,
>> >>
>> >> But your "5 seconds" timings are suspect, too.
>> >>
>> >> Are you running on a tiny, tiny machine, or on a busy server with just
>> >> all kinds of other stuff going on?
>> >>
>> >> You ought to be able to fetch both tables and the join in five seconds
>> >> easy, even with no keys at all, on anything like a current machine.
>> >>
>> >> J.
>> >>
>> >>
>> >> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
>> >> <TLD@.discussions.microsoft.com> wrote:
>> >>
>> >> >The following query takes almost two minutes to run:
>> >> >
>> >> >SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>> >> >Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>> >> >FROM dbo.tblAccounts LEFT OUTER JOIN
>> >> > Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =>> >> >Reference.dbo.tlkpInstruments.IDInstrument
>> >> >
>> >> >tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>> >> >All rows retrieved in less than 5 seconds.
>> >> >
>> >> >tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
>> >> >All rows retrieved in less than 5 seconds.
>> >> >
>> >> >Why is the query running so slowly?
>> >> >
>> >> >Thanks.
>> >>
>> >>
>>|||It's still shocking that these queries take more than a second to execute.
JXStern wrote:
> On Sun, 28 Jan 2007 10:28:01 -0800, TLD
> <TLD@.discussions.microsoft.com> wrote:
>> That was from Query Analyzer (five seconds) on the local system. I also
>> tested on a network with the Access front end on a 2G Thinkpad (5400 rpm
>> disk) with 1G of memory. There it runs in just under 30 seconds, which is
>> equivalent to the opening of the main form.
>> Thanks for your help.
> So, was VS open on the "server"?
> If I helped, you're welcome,
> but I guess I'm still mystified.
> J.
>
>> "JXStern" wrote:
>> On Sun, 28 Jan 2007 08:46:00 -0800, TLD
>> <TLD@.discussions.microsoft.com> wrote:
>> The problem has been solved. By reworking my front end, I was able to
>> eliminate some of the fields in the query. Now it runs in less than five
>> seconds.
>> Aha. Was that five seconds / two minutes to your app, or were those
>> timings from the query analyzer? I've seen situations where the front
>> end was busy and didn't accept the results for thirty seconds or more,
>> especially if all development is being done on a single system, was
>> that your situation?
>> Not to mention, a dual-64 with (only!) 2gb RAM, running SQLServer and
>> an open instance of VS, might be running short of memory - VS being an
>> unbelievable pig. Might run a lot faster on even a small server over
>> the network.
>> J.
>>
>>
>> Thanks to all for your help.
>> "JXStern" wrote:
>> The two minutes is slow, of course,
>> But your "5 seconds" timings are suspect, too.
>> Are you running on a tiny, tiny machine, or on a busy server with just
>> all kinds of other stuff going on?
>> You ought to be able to fetch both tables and the join in five seconds
>> easy, even with no keys at all, on anything like a current machine.
>> J.
>>
>> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
>> <TLD@.discussions.microsoft.com> wrote:
>> The following query takes almost two minutes to run:
>> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>> >FROM dbo.tblAccounts LEFT OUTER JOIN
>> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =>> Reference.dbo.tlkpInstruments.IDInstrument
>> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>> All rows retrieved in less than 5 seconds.
>> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
>> All rows retrieved in less than 5 seconds.
>> Why is the query running so slowly?
>> Thanks.
>>
>
-Dave Markle
http://www.markleconsulting.com/blog|||You're not the only one who's mystified.
The summary is this:
When the query had the field TriggerContracts plus those following, it took
1m55s to run locally on workstation, 2m20s to run on networked laptop. When
the number of fields was reduced, it took 5s to run locally on workstation,
30s to run on networked laptop. It didn't matter which fields were there; it
was purely the number of them.
What I've learned from all of this is that, to test a join you should use
only one field from each table.
Thanks again,
Tom
"Dave Markle" <"dma[remove_ZZ]ZZrkle" wrote:
> It's still shocking that these queries take more than a second to execute.
> JXStern wrote:
> > On Sun, 28 Jan 2007 10:28:01 -0800, TLD
> > <TLD@.discussions.microsoft.com> wrote:
> >
> >> That was from Query Analyzer (five seconds) on the local system. I also
> >> tested on a network with the Access front end on a 2G Thinkpad (5400 rpm
> >> disk) with 1G of memory. There it runs in just under 30 seconds, which is
> >> equivalent to the opening of the main form.
> >>
> >> Thanks for your help.
> >
> > So, was VS open on the "server"?
> >
> > If I helped, you're welcome,
> > but I guess I'm still mystified.
> >
> > J.
> >
> >
> >
> >>
> >> "JXStern" wrote:
> >>
> >> On Sun, 28 Jan 2007 08:46:00 -0800, TLD
> >> <TLD@.discussions.microsoft.com> wrote:
> >>
> >> The problem has been solved. By reworking my front end, I was able to
> >> eliminate some of the fields in the query. Now it runs in less than five
> >> seconds.
> >> Aha. Was that five seconds / two minutes to your app, or were those
> >> timings from the query analyzer? I've seen situations where the front
> >> end was busy and didn't accept the results for thirty seconds or more,
> >> especially if all development is being done on a single system, was
> >> that your situation?
> >>
> >> Not to mention, a dual-64 with (only!) 2gb RAM, running SQLServer and
> >> an open instance of VS, might be running short of memory - VS being an
> >> unbelievable pig. Might run a lot faster on even a small server over
> >> the network.
> >>
> >> J.
> >>
> >>
> >>
> >>
> >> Thanks to all for your help.
> >>
> >> "JXStern" wrote:
> >>
> >> The two minutes is slow, of course,
> >>
> >> But your "5 seconds" timings are suspect, too.
> >>
> >> Are you running on a tiny, tiny machine, or on a busy server with just
> >> all kinds of other stuff going on?
> >>
> >> You ought to be able to fetch both tables and the join in five seconds
> >> easy, even with no keys at all, on anything like a current machine.
> >>
> >> J.
> >>
> >>
> >> On Fri, 26 Jan 2007 09:38:01 -0800, TLD
> >> <TLD@.discussions.microsoft.com> wrote:
> >>
> >> The following query takes almost two minutes to run:
> >>
> >> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> >> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> >> >FROM dbo.tblAccounts LEFT OUTER JOIN
> >> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities => >> Reference.dbo.tlkpInstruments.IDInstrument
> >>
> >> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> >> All rows retrieved in less than 5 seconds.
> >>
> >> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int).
> >> All rows retrieved in less than 5 seconds.
> >>
> >> Why is the query running so slowly?
> >>
> >> Thanks.
> >>
> >>
> >
>
> --
> -Dave Markle
> http://www.markleconsulting.com/blog
>

Performance of query joining tables linked between different datab

The following query takes almost two minutes to run:
SELECT Reference.dbo.tlkpInstruments.IDInstrument,
Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
FROM dbo.tblAccounts LEFT OUTER JOIN
Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =
Reference.dbo.tlkpInstruments.IDInstrument
tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
All rows retrieved in less than 5 seconds.
tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int)
.
All rows retrieved in less than 5 seconds.
Why is the query running so slowly?
Thanks.Start by adding indexes on the columns that you do the join over. Also consi
der making one or even
both of the indexes clustered indexes (assuming that is suitable).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"TLD" <TLD@.discussions.microsoft.com> wrote in message
news:5FF860E0-152C-4C5C-AB90-1FA78D9E05B1@.microsoft.com...
> The following query takes almost two minutes to run:
> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> FROM dbo.tblAccounts LEFT OUTER JOIN
> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =
> Reference.dbo.tlkpInstruments.IDInstrument
> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> All rows retrieved in less than 5 seconds.
> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (in
t).
> All rows retrieved in less than 5 seconds.
> Why is the query running so slowly?
> Thanks.|||Here are table and index definitions:
CREATE TABLE [dbo].[tblAccounts] (
[AccID] [bigint] NOT NULL ,
[OffID] [int] NOT NULL ,
[ID] [bigint] NULL ,
[AccNo] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AccName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Office] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Level] [tinyint] NULL ,
[3rdPartyGty] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NU
LL ,
[Division] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[USRating] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[UKRating] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[InitReqmnts] [int] NULL ,
[StressExposure] [int] NULL ,
[MarDefExcess] [int] NULL ,
[ARTL] [int] NULL ,
[SRTL] [int] NULL ,
[IMTL] [int] NULL ,
[PCOvr] [tinyint] NULL ,
[Action] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[EvalDate] [smalldatetime] NULL ,
[RenewDate] [smalldatetime] NULL ,
[LevelPrevious] [int] NULL ,
[EvalDatePrevious] [smalldatetime] NULL ,
[Note] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Exclude] [bit] NULL ,
[NetLiquidity] [int] NULL ,
[MaxRisk] [int] NULL ,
[NotAmt] [int] NULL ,
[MarReqd] [int] NULL ,
[Country] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[SHEquity] [int] NULL ,
[EstProfit] [int] NULL ,
[Exposure] [numeric](10, 2) NULL ,
[Options] [bit] NULL ,
[Contracts] [int] NULL ,
[Symbol] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PriceCurrent] [money] NULL ,
[PriceHistoric] [money] NULL ,
[Documentation] [bit] NULL ,
[Commodities] [int] NULL ,
[Comment] [varchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[MD] [bit] NULL ,
[Diversified] [smallint] NULL ,
[Doc] [smallint] NULL ,
[Credit] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Legal] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Accepted] [smallint] NULL ,
[Man] [bit] NULL ,
[TriggerContracts] [int] NULL ,
[Inst] [nvarchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
CREATE UNIQUE CLUSTERED
INDEX [PK_tblAccounts] ON [dbo].[tblAccounts] ([AccID], [
;OffID],
[Commodities])
WITH
FILLFACTOR = 90
,DROP_EXISTING
ON [PRIMARY]
CREATE TABLE [dbo].[tlkpInstruments] (
[IDInstrument] [int] IDENTITY (1, 1) NOT NULL ,
[Instrument] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NO
T NULL ,
[Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ExchangeID] [int] NOT NULL ,
[GroupID] [int] NULL ,
[Collective] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NU
LL
) ON [PRIMARY]
CREATE UNIQUE CLUSTERED
INDEX [PK_tlkpInstruments] ON [dbo].[tlkpInstruments] ([IDIn
strument])
WITH
DROP_EXISTING
ON [PRIMARY]
"TLD" wrote:

> The following query takes almost two minutes to run:
> SELECT Reference.dbo.tlkpInstruments.IDInstrument,
> Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
> FROM dbo.tblAccounts LEFT OUTER JOIN
> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =
> Reference.dbo.tlkpInstruments.IDInstrument
> tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
> All rows retrieved in less than 5 seconds.
> tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (in
t).
> All rows retrieved in less than 5 seconds.
> Why is the query running so slowly?
> Thanks.|||The two minutes is slow, of course,
But your "5 seconds" timings are suspect, too.
Are you running on a tiny, tiny machine, or on a busy server with just
all kinds of other stuff going on?
You ought to be able to fetch both tables and the join in five seconds
easy, even with no keys at all, on anything like a current machine.
J.
On Fri, 26 Jan 2007 09:38:01 -0800, TLD
<TLD@.discussions.microsoft.com> wrote:

>The following query takes almost two minutes to run:
>SELECT Reference.dbo.tlkpInstruments.IDInstrument,
>Reference.dbo.tlkpInstruments.Instrument, dbo.tblAccounts.*
>FROM dbo.tblAccounts LEFT OUTER JOIN
> Reference.dbo.tlkpInstruments ON dbo.tblAccounts.Commodities =
>Reference.dbo.tlkpInstruments.IDInstrument
>tlkpInstruments contains 4140 rows. Primary key is IDInstrument (int).
>All rows retrieved in less than 5 seconds.
>tblAccounts contains 43348 rows. Primary key is AccID (bigint) + OffID (int
).
>All rows retrieved in less than 5 seconds.
>Why is the query running so slowly?
>Thanks.