473,598 Members | 2,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Odd Stored Procedure Behavior

I'm seeing some really messed up behavior from a stored procedure. Here is
the DDL:

CREATE PROCEDURE AIM.GetUserIDRe trievals (IN strUserID VARCHAR(64),
IN decAIMConnectio nID DECIMAL(13,0))
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
SPECIFIC AIM.GetUserIDRe trieval
LANGUAGE SQL
RESULT SETS 1
P1: BEGIN
DECLARE SELECT_CURSOR CURSOR WITH RETURN FOR
SELECT AIM.AIMRETRIEVA L.AIMRETRIEVALI D, AIM.AIMRETRIEVA L.DESCRIPTION,
AIM.ARCHIVERETR IEVAL.ARCHIVERE TRIEVALID, AIM.ARCHIVERETR IEVAL.STATUSID,
AIM.ARCHIVERETR IEVAL.EXPIRATIO NDATE,
AIM.ARCHIVERETR IEVAL.ESTIMATED RESPONSETIME,
AIM.ARCHIVERETR IEVAL.ARCHIVERE TRIEVALRECEIPT,
AIM.ARCHIVERETR IEVAL.ITEMCOUNT ,
(SELECT AIM.ARCHIVERETR IEVAL.ITEMCOUNT -
COUNT(AIM.AIMRE TRIEVEDITEM.AIM RETRIEVEDITEMID ) FROM AIM.AIMRETRIEVE DITEM
WHERE
(AIM.AIMRETRIEV EDITEM.ARCHIVER ETRIEVALID =
AIM.ARCHIVERETR IEVAL.ARCHIVERE TRIEVALID) AND
LENGTH(AIM.AIMR ETRIEVEDITEM.IM AGEFRONT) IS NULL)
AS NUMBERIMAGESAVA ILABLE
FROM
AIM.AIMCONNECTI ON,
AIM.AIMQUERY,
AIM.AIMRETRIEVA L,
AIM.ARCHIVERETR IEVAL,
AIM.AIMRETRIEVE DITEM,
AIM.ARCHIVETYPE ,
AIM.CHANNEL
WHERE
AIM.AIMCONNECTI ON.AIMCONNECTIO NID = AIM.AIMQUERY.AI MCONNECTIONID
AND AIM.AIMQUERY.AI MQUERYID = AIM.AIMRETRIEVA L.AIMQUERYID
AND AIM.AIMRETRIEVA L.AIMRETRIEVALI D = AIM.ARCHIVERETR IEVAL.AIMRETRIE VALID
AND AIM.ARCHIVERETR IEVAL.ARCHIVERE TRIEVALID =
AIM.AIMRETRIEVE DITEM.ARCHIVERE TRIEVALID
AND AIM.ARCHIVERETR IEVAL.ARCHIVEID = AIM.ARCHIVETYPE .ARCHIVEID
AND (AIM.ARCHIVERET RIEVAL.EXPIRATI ONDATE >= DATE(CURRENT TIMESTAMP) OR
(AIM.ARCHIVERET RIEVAL.EXPIRATI ONDATE IS NULL AND
AIM.ARCHIVERETR IEVAL.ESTIMATED RESPONSETIME >= CURRENT TIMESTAMP))
AND AIM.ARCHIVETYPE .ARCHIVETYPE = 'D'
AND AIM.AIMCONNECTI ON.USERID = strUserID
AND AIM.CHANNEL.CHA NNEL =
(SELECT CHANNEL FROM AIM.CHANNEL, AIM.CHANNELSESS ION, AIM.AIMCONNECTI ON
WHERE
AIM.CHANNELSESS ION.CHANNELSESS IONID = AIM.AIMCONNECTI ON.CHANNELSESSI ONID
AND AIM.CHANNELSESS ION.CHANNELID = AIM.CHANNEL.CHA NNELID
AND AIM.AIMCONNECTI ON.AIMCONNECTIO NID = decAIMConnectio nID)
GROUP BY AIM.AIMRETRIEVA L.AIMRETRIEVALI D, AIM.AIMRETRIEVA L.DESCRIPTION,
AIM.ARCHIVERETR IEVAL.ARCHIVERE TRIEVALID, AIM.ARCHIVERETR IEVAL.STATUSID,
AIM.ARCHIVERETR IEVAL.EXPIRATIO NDATE,
AIM.ARCHIVERETR IEVAL.ESTIMATED RESPONSETIME,
AIM.ARCHIVERETR IEVAL.ARCHIVERE TRIEVALRECEIPT,
AIM.ARCHIVERETR IEVAL.ITEMCOUNT ,
AIM.ARCHIVERETR IEVAL.ITEMCOUNT
ORDER BY AIMRETRIEVALID;
OPEN SELECT_CURSOR;
END P1

For some reason this procedure is running absolutely dog slow!!!! If I run
the SQL in the procedure ad-hoc (command line, etc.), the query completes
sub-second; the procedure takes about three minutes to return the result
set...

Can anyone shed any light on what the issue may be?!? Do stored procedures
run in a different memory pool or something? Does the query optimizer need
some help?

Any help would be greatly appreciated!!!

AMR
Nov 12 '05 #1
0 1218

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7965
by: TJ Olaes | last post by:
Hello all, this is my second post to this newsgroup. It's a question about stored procedures and permissions and how these behave between databases. Here's the scenario. I have a database that stores information for a system "A", and I have a different database on the same SQL server that stores the login and other info "LOGIN". I write a stored procedure in the "A" database that checks some tables in the "LOGIN" database, let's call...
4
2573
by: Dan | last post by:
I've encountered some strange behavior in a recursive procedure I'm writing for a bill of materials. First let me ask directly if what I think is happening is even possible: It seems like the procedure is not following the recursion in serial order, but in parallel. In other words, after one instance of the procedure calls itself, it continues executing lines below the recursion before the recursion is done. Is that possible? I...
7
5668
by: Anthony Robinson | last post by:
Have been encountering an odd issue. Every now and again, certain packages of stored procedures just become invalid. I'm aware that dropping or altering an underlying table would render a package invalid, but we are doing no such thing... After banging my head on the wall for a bit I noticed that the two stored procedures that are experiencing this behavior are procedures that are called from within another procedure (they're not both...
2
5449
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
2
3493
by: TJS | last post by:
in a script, a stored procedure is called. I want to verify the procedure is complete before proceeding ahead. How can I have the script wait until a stored procedure is verified as complete before proceeding ahead ??
0
2139
by: george | last post by:
Hi world! Anyone experienced building gridview in Oracle environment using stored procedures, please help! Right now, I have issues using Oracle SP, I spent a whole day on this and still cannot get the results back, so shamelessly turn to you for help! OK, the web page part of SqlDataSource is defined as: <asp:SqlDataSource ID="SqlDataSource4" runat="server"
1
1598
by: brianlanning | last post by:
We have a stored procedure that we've tried with two slightly different designs. It needs to take a 30 day date range and return a result set. Design 1 takes one date as a parameter. The other date is calculated in a local variable to be 30 days before the one that was passed in. Both data types are datetime and are in the where clause. Design 2 takes two dates as parameters with the 30 days being calculated outside the stored...
2
5079
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have coded multiple select statements in a single stored procedure, and when I execute this procedure on SQL Server Management Express, I correctly get multiple result sets. But, if I try to add a new Data Source to to my VB 2005 project, and point to this stored procedure, the data source wizard only sees the 'first' select statement. Is there a way to load multiple tables in a DataSet from a single stored procedure with multiple...
0
2744
by: zaza24 | last post by:
Hello there I am loosing my time since a few days trying to install a CRM (ACT! 2008 version 10) software on a brand new HP notebook with Vista prof OS. Ths installation do not show any troubles and works fine; the software installs also Microsoft SQL Server Express 2005 (the different services installed are SQL Server for ACT7, SQL server Active Directory Helper, SQL Server Browser and SQL Server VSS Writer). SQL Service for ACT7 is in...
0
7981
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8262
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3894
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2410
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.