473,545 Members | 386 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 1739
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
4277
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
3237
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
3286
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
4199
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
7467
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
7401
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...
1
5326
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...
0
4944
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...
0
3450
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
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
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
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
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.