473,587 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query performance question

Hello. I have query performance question.
I need to optimize procedure

CREATE PROCEDURE dbo.SECUQUSRCOM PACCES
@P1 VARCHAR(50),
@P2 INTEGER
AS
DECLARE @IORGANIZATIONI D INTEGER
EXECUTE dbo.ORGNQGETORG ID @PORGUNIQUEID = @IORGANIZATIONI D OUTPUT

SELECT TSECCOMP.ID,
CASE TSECPROFILEGRP. ACCESSTYPE
WHEN -1 THEN
CASE TSECCLASS.DEFAU LTACCESS
WHEN -1 THEN
CASE TSECGROUPCOMP.D EFAULTACCESS
WHEN -1 THEN
TSECCOMP.DEFAUL TACCESS
ELSE
TSECGROUPCOMP.D EFAULTACCESS
END

ELSE
TSECCLASS.DEFAU LTACCESS
END
ELSE TSECPROFILEGRP. ACCESSTYPE
END AS EXPR1
FROM TSECCOMP
INNER JOIN ((TSECPROFILE
INNER JOIN (TSECCLASS
INNER JOIN TSECPROFILEGRP
ON TSECCLASS.UNIQU EID = TSECPROFILEGRP. SECURITYGROUPID )
ON TSECPROFILE.UNI QUEID = TSECPROFILEGRP. PROFILEID) INNER JOIN
TSECGROUPCOMP ON TSECCLASS.UNIQU EID = TSECGROUPCOMP.S ECURITYGROUPID)
ON TSECCOMP.UNIQUE ID = TSECGROUPCOMP.S ECCOMPID
WHERE
(
CASE TSECPROFILEGRP. ACCESSTYPE
WHEN -1 THEN
CASE TSECCLASS.DEFAU LTACCESS
WHEN -1 THEN
CASE TSECGROUPCOMP.D EFAULTACCESS
WHEN -1 THEN
TSECCOMP.DEFAUL TACCESS
ELSE
TSECGROUPCOMP.D EFAULTACCESS
END
ELSE
TSECCLASS.DEFAU LTACCESS
END
ELSE TSECPROFILEGRP. ACCESSTYPE
END > 0 ) AND (TSECPROFILE.KE YVALUE=@P1) AND ( TSECCOMP.TYPE =@P2)
AND TSECCOMP.ORGANI ZATIONID = @IORGANIZATIONI D
GO
Thank you In advance.
Jul 20 '05 #1
2 1741
Make sure you have indexed the join keys. You can try running the Index
Tuning Wizard for advice.

Gert-Jan
inna wrote:

Hello. I have query performance question.
I need to optimize procedure

CREATE PROCEDURE dbo.SECUQUSRCOM PACCES
@P1 VARCHAR(50),
@P2 INTEGER
AS
DECLARE @IORGANIZATIONI D INTEGER
EXECUTE dbo.ORGNQGETORG ID @PORGUNIQUEID = @IORGANIZATIONI D OUTPUT

SELECT TSECCOMP.ID,
CASE TSECPROFILEGRP. ACCESSTYPE
WHEN -1 THEN
CASE TSECCLASS.DEFAU LTACCESS
WHEN -1 THEN
CASE TSECGROUPCOMP.D EFAULTACCESS
WHEN -1 THEN
TSECCOMP.DEFAUL TACCESS
ELSE
TSECGROUPCOMP.D EFAULTACCESS
END

ELSE
TSECCLASS.DEFAU LTACCESS
END
ELSE TSECPROFILEGRP. ACCESSTYPE
END AS EXPR1
FROM TSECCOMP
INNER JOIN ((TSECPROFILE
INNER JOIN (TSECCLASS
INNER JOIN TSECPROFILEGRP
ON TSECCLASS.UNIQU EID = TSECPROFILEGRP. SECURITYGROUPID )
ON TSECPROFILE.UNI QUEID = TSECPROFILEGRP. PROFILEID) INNER JOIN
TSECGROUPCOMP ON TSECCLASS.UNIQU EID = TSECGROUPCOMP.S ECURITYGROUPID)
ON TSECCOMP.UNIQUE ID = TSECGROUPCOMP.S ECCOMPID
WHERE
(
CASE TSECPROFILEGRP. ACCESSTYPE
WHEN -1 THEN
CASE TSECCLASS.DEFAU LTACCESS
WHEN -1 THEN
CASE TSECGROUPCOMP.D EFAULTACCESS
WHEN -1 THEN
TSECCOMP.DEFAUL TACCESS
ELSE
TSECGROUPCOMP.D EFAULTACCESS
END
ELSE
TSECCLASS.DEFAU LTACCESS
END
ELSE TSECPROFILEGRP. ACCESSTYPE
END > 0 ) AND (TSECPROFILE.KE YVALUE=@P1) AND ( TSECCOMP.TYPE =@P2)
AND TSECCOMP.ORGANI ZATIONID = @IORGANIZATIONI D
GO
Thank you In advance.

Jul 20 '05 #2
Hi

Check out the query execution plan

http://www.sql-server-performance.co...n_analysis.asp

http://www.sql-server-performance.com/transact_sql.asp

John
"inna" <me****@hotmail .com> wrote in message
news:34******** *************** ***@posting.goo gle.com...
Hello. I have query performance question.
I need to optimize procedure

CREATE PROCEDURE dbo.SECUQUSRCOM PACCES
@P1 VARCHAR(50),
@P2 INTEGER
AS
DECLARE @IORGANIZATIONI D INTEGER
EXECUTE dbo.ORGNQGETORG ID @PORGUNIQUEID = @IORGANIZATIONI D OUTPUT

SELECT TSECCOMP.ID,
CASE TSECPROFILEGRP. ACCESSTYPE
WHEN -1 THEN
CASE TSECCLASS.DEFAU LTACCESS
WHEN -1 THEN
CASE TSECGROUPCOMP.D EFAULTACCESS
WHEN -1 THEN
TSECCOMP.DEFAUL TACCESS
ELSE
TSECGROUPCOMP.D EFAULTACCESS
END

ELSE
TSECCLASS.DEFAU LTACCESS
END
ELSE TSECPROFILEGRP. ACCESSTYPE
END AS EXPR1
FROM TSECCOMP
INNER JOIN ((TSECPROFILE
INNER JOIN (TSECCLASS
INNER JOIN TSECPROFILEGRP
ON TSECCLASS.UNIQU EID = TSECPROFILEGRP. SECURITYGROUPID )
ON TSECPROFILE.UNI QUEID = TSECPROFILEGRP. PROFILEID) INNER JOIN
TSECGROUPCOMP ON TSECCLASS.UNIQU EID = TSECGROUPCOMP.S ECURITYGROUPID)
ON TSECCOMP.UNIQUE ID = TSECGROUPCOMP.S ECCOMPID
WHERE
(
CASE TSECPROFILEGRP. ACCESSTYPE
WHEN -1 THEN
CASE TSECCLASS.DEFAU LTACCESS
WHEN -1 THEN
CASE TSECGROUPCOMP.D EFAULTACCESS
WHEN -1 THEN
TSECCOMP.DEFAUL TACCESS
ELSE
TSECGROUPCOMP.D EFAULTACCESS
END
ELSE
TSECCLASS.DEFAU LTACCESS
END
ELSE TSECPROFILEGRP. ACCESSTYPE
END > 0 ) AND (TSECPROFILE.KE YVALUE=@P1) AND ( TSECCOMP.TYPE =@P2)
AND TSECCOMP.ORGANI ZATIONID = @IORGANIZATIONI D
GO
Thank you In advance.

Jul 20 '05 #3

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

Similar topics

1
4278
by: Paul | last post by:
Assume you have two varchar (or Text) columns named L and U which are identical except that the charset for L is latin1 and the charset for U is utf8. All the records in L and U are identical in terms of content, consisting of only 7 bit ASCII characters. Both columns have indexes of the same type (e.g. assume Unique indexes if you want). ...
8
3244
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run simultaneously 4 similar queries it takes nearly 5 minutes instead of 4 times 9 seconds or something near of that. here is a sample query: select ...
0
3289
by: phlype.johnson | last post by:
I'm struggling to find the best query from performance point of view and readability for a normalized DB design. To illustrate better my question on whether normalized designs lead to more complex queries yes or no, I have prepared an example. The example is a database with the following tables: *table person with fields: -persid:...
1
4205
by: Jimbo | last post by:
I have a query..if you look at the bottom of the where clause you'll see an "NOT IN" statement that is really hanging up the query..i'm trying to replace with a "NOT EXISTS" but it isnt appearing to work...I need to get a result set where the email address of the outter most query is not in that sub query...thanks: -->Code Begins Here ...
0
7923
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...
0
7852
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8349
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...
1
7974
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...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3845
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...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
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...

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.