Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:57:14+00:00 2026-06-14T06:57:14+00:00

I am trying to optimize a Crystal Report that is used very frequently here.

  • 0

I am trying to optimize a Crystal Report that is used very frequently here. I succeeded to optimize lots of queries but I still have one last bottleneck: This is the main query, generated from the report.

SELECT
    A.*,
    B.*,
    C.*,
    D.*,
    E."N",
    F."N",
    G."N"
FROM
    A
LEFT OUTER JOIN B ON
    A."PK" = B."FK"
LEFT OUTER JOIN C ON
    A."PK" = C."FK"
LEFT OUTER JOIN D ON
    A."FK" = D."PK"
LEFT OUTER JOIN E ON
    A."PK" = E."FK"
LEFT OUTER JOIN F ON
    A."PK" = F."FK"
LEFT OUTER JOIN G ON
    A."PK" = G."FK"
WHERE A.PK = ####

A,B,C and D are tables. E,F,G are simple views.

As you see, the report generated multiple LEFT JOINS. This query takes 2.28 seconds to complete (From the Plan Viewer stats). I identified three joins that seem problematic. If I remove E,F,G from the query, it becomes almost instant (0.0009s from the same stats)

SELECT
    A.*,
    B.*,
    C.*,
    D.*
FROM
    A
LEFT OUTER JOIN B ON
    A."PK" = B."FK"
LEFT OUTER JOIN C ON
    A."PK" = C."FK"
LEFT OUTER JOIN D ON
    A."FK" = D."PK"
WHERE A.PK = ####

I tought it might be the views that are slow, but if I do for example …

SELECT *
FROM E
WHERE E.FK = ####

… it is also almost instant (0.0009s)

Tables all have indexes on PKs-FKs.
Views E,F,G all return one or no row with [FK|N] as columns, so the resulting column is NULL or a number.

Do you know how I could make this query fast?

PS: If I replace LEFT OUTER JOINS by INNER JOINS the main query becomes fast… :-/

Or trying to split this query into multiple queries on the report would be a better solution?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:57:16+00:00Added an answer on June 14, 2026 at 6:57 am

    I would create functions for the lookup against E, F and G instead of joining them.
    That way there is little chance the optimiser gets confused and tries to do stupid things.

    SELECT
        A.*,
        B.*,
        C.*,
        D.*,
        GET_E(A."PK"),
        GET_F(A."PK"),
        GET_G(A."PK")
    FROM
        A
    LEFT OUTER JOIN B ON
        A."PK" = B."FK"
    LEFT OUTER JOIN C ON
        A."PK" = C."FK"
    LEFT OUTER JOIN D ON
        A."FK" = D."PK"
    WHERE A.PK = ####
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to optimize this query as good as possible,but still i am
I'm trying to optimize code that I have. In order to do that, I
I am trying to optimize my MySQL queries and I need some help. Here
I'm trying to optimize my queries a bit but can't quite get it right.
I'm trying to optimize my queries throughout my site. I have 3 models, Photo,
I'm trying to optimize my code using Neon intrinsics. I have a 24-bit rotation
I'm currently trying to optimize my program. I have a large database which consists
I'm trying to optimize the size of my Delphi classes so that they take
I am trying to optimize generic lists arithmetic operation. I have 3 lists of
I am trying to optimize a small, highly used function which uses the high

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.