Replacement of CROSS APPLY statement

Tags:
CROSS APPLY statement
SQL Server 2005
SQL Server 2005 connectivity
1. I am running query in which cross apply operator is used 2. That same query exceutes more than 10 times 3. Due to cross apply it increase the time to excute the report

Answer Wiki

Thanks. We'll let you know when a new response is added.

<b>Background Information:</b>

The CROSS APPLY does a Cartesian join between the tables. Depending on what’s being joined, this can cause the run time of the query to increase as SQL is taking the number of rows in the first table times the number or rows in the second.

CROSS APPLY <i>can</i> solve some problems that would be very difficult to solve other ways, but it is often not the best answer. In some cases, it IS the best answer (I’ve used it with a linked server query in a way that resulted in hundreds of times performance improvement).

<b>Answer</b>

Are you sure that the CROSS APPLY is the correct thing to do? What result are you trying to get?

Please post the query you are using. If CROSS APPLY is using a function, please post the function declaration.

It would also probably be useful to have the DDL for the tables involved, and possibly the indexes, too. Right-click on the table and script to the clipboard.

With more information we can provide you with a better answer.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Emtucifor
    Please post the query you are using. If CROSS APPLY is using a function, please post the function declaration. It would also probably be useful to have the DDL for the tables involved, and possibly the indexes, too. Right-click on the table and script to the clipboard. CROSS APPLY can solve some problems that would be very difficult to solve other ways, but it is often not the best answer. In some cases, it IS the best answer (I've used it with a linked server query in a way that resulted in hundreds of times performance improvement).
    50 pointsBadges:
    report
  • Emtucifor
    Clearly I didn't know how to use this site. Please ignore my discussion comment I posted.
    50 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following