Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Which of the two queries is better ??? Expand / Collapse
Author
Message
Posted Wednesday, April 10, 2013 9:25 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 2:58 AM
Points: 718, Visits: 543
Hard coded value is coming from SITE_AC table. Now it is not there because I had removed some rows from script to reduce the size of attachment. you can put any value.

Post #1440883
Posted Wednesday, April 10, 2013 9:30 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:56 AM
Points: 7,137, Visits: 13,527
T.Ashish (4/10/2013)
Hard coded value is coming from SITE_AC table. Now it is not there because I had removed some rows from script to reduce the size of attachment. you can put any value.



When you run your Big Query, do you have a WHERE clause as you do in your sample? Like this:

WHERE site_id =

If so, where does the value ('0a1705011715553107773972') come from? Is it a parameter?


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1440887
Posted Wednesday, April 10, 2013 9:23 PM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 2:58 AM
Points: 718, Visits: 543
It comes from Java Code, like ......where Site_id = :lablesiteid....

Post #1441096
Posted Thursday, April 11, 2013 1:07 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:56 AM
Points: 7,137, Visits: 13,527
T.Ashish (4/10/2013)
It comes from Java Code, like ......where Site_id = :lablesiteid....



-- Query 2
SELECT
TOP 100 comp_id,
sup_code,
sup_name,
sup_ac_code,(
SELECT
top 1 site_id
FROM
site_ac
WHERE
site_id = '0a1705011715553107773972'
) AS z
FROM
comp_ac
ORDER BY
comp_id

-- why not just do this?
SELECT
TOP 100 comp_id,
sup_code,
sup_name,
sup_ac_code,
'0a1705011715553107773972' AS z
FROM
comp_ac
ORDER BY
comp_id



“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1441128
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse