Just a guess.
It might be the delay in creating and opening the connection.
Why don't you log the current time just before calling the SP and after it
and find the time difference. That can narrow down on what the issue is.
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/
"Boaz Ben-Porat" wrote:
> Computer: 3.4 Ghz CPU, 1 GB RAM, 2003 Server
> database : MS SqlServer 2000 Enterprise. ~ 10 GB database file. Largest
> table in the database contains 11,000,000 records.
> Framework: .NET 2.0
> I try to run a query against the database, selecting aggregated data from
> views based on the large table.
> When executed from the Query Analizer, it takes 13 seconds.
> When executed from a .NET application, it takes 140 seconds.
> The database is well tuned (or else the query analizer would go slowly), s
o
> I can't find the reason for this difference.
> Any suggestion ?
> TIA
> Boaz Ben-Porat
> Milestone Systems
>
>Thanks for a quick answer.
The time I refer to is after the connection is opened.
the relevant code:
DbDataReader dr = null;
try
{
// This method opens a connection, if not allready opened
Connect();
// dbCommand is an input parameter of type DbCommand. It contains the SQL
statement
dbCommand.Connection = _connection;
DateTime t1 = DateTime.Now;
dr = dbCommand.ExecuteReader();
DateTime t2 = DateTime.Now;
TimeSpan ts = t2 - t1;
int milli = (int)ts.TotalMilliseconds; // milli contains the execution time
of dbCommand.ExecuteReader();
Boaz Ben-Porat
"Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
news:49A213DD-227B-4602-81ED-5ADF4E32687E@.microsoft.com...
> Just a guess.
> It might be the delay in creating and opening the connection.
> Why don't you log the current time just before calling the SP and after it
> and find the time difference. That can narrow down on what the issue is.
> --
> -Omnibuzz (The SQL GC)
> http://omnibuzz-sql.blogspot.com/
>
> "Boaz Ben-Porat" wrote:
>
Showing posts with label guess. Show all posts
Showing posts with label guess. Show all posts
Friday, February 24, 2012
Monday, February 13, 2012
a little SQL problem
I have what is probably a simple problem and I guess I'm just looking
for whatever solutions you all can suggest...
I have this query:
Select columnA , sum(columnB) as VAL from myTable where
columnA in ('01,'02') group by columnA
which may return:
columnA VAL
-- --
01 100.00
02 200.00
Just using SQL, I'd like to return a table that looks like:
columnA VAL
-- --
01 300.00
and I don't want to use the query:
Select '01', sum(columnB) as VAL from myTable where
columnA in ('01','02')
Any suggestions? Your help is much appreciated.
Marcbrownjenkn@.aol.com wrote:
> I have what is probably a simple problem and I guess I'm just looking
> for whatever solutions you all can suggest...
> I have this query:
> Select columnA , sum(columnB) as VAL from myTable where
> columnA in ('01,'02') group by columnA
> which may return:
> columnA VAL
> -- --
> 01 100.00
> 02 200.00
> Just using SQL, I'd like to return a table that looks like:
> columnA VAL
> -- --
> 01 300.00
>
> and I don't want to use the query:
> Select '01', sum(columnB) as VAL from myTable where
> columnA in ('01','02')
> Any suggestions? Your help is much appreciated.
> Marc
Maybe like this:
SELECT MIN(columnA) AS columnA, SUM(columnB) AS val
FROM myTable
WHERE columnA IN ('01','02');
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
for whatever solutions you all can suggest...
I have this query:
Select columnA , sum(columnB) as VAL from myTable where
columnA in ('01,'02') group by columnA
which may return:
columnA VAL
-- --
01 100.00
02 200.00
Just using SQL, I'd like to return a table that looks like:
columnA VAL
-- --
01 300.00
and I don't want to use the query:
Select '01', sum(columnB) as VAL from myTable where
columnA in ('01','02')
Any suggestions? Your help is much appreciated.
Marcbrownjenkn@.aol.com wrote:
> I have what is probably a simple problem and I guess I'm just looking
> for whatever solutions you all can suggest...
> I have this query:
> Select columnA , sum(columnB) as VAL from myTable where
> columnA in ('01,'02') group by columnA
> which may return:
> columnA VAL
> -- --
> 01 100.00
> 02 200.00
> Just using SQL, I'd like to return a table that looks like:
> columnA VAL
> -- --
> 01 300.00
>
> and I don't want to use the query:
> Select '01', sum(columnB) as VAL from myTable where
> columnA in ('01','02')
> Any suggestions? Your help is much appreciated.
> Marc
Maybe like this:
SELECT MIN(columnA) AS columnA, SUM(columnB) AS val
FROM myTable
WHERE columnA IN ('01','02');
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Subscribe to:
Posts (Atom)