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 3935722
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:51:45+00:00 2026-05-19T23:51:45+00:00

An old system have arrived on our office for some changes and fix, but

  • 0

An old system have arrived on our office for some changes and fix, but it is also suffering from performance issues. We don’t know exactly what is the source of this slowness.

While we were refactoring the old code we found several sql queries with the follow pattern (the queries are simplified for example purpose):

SELECT
   (
    SELECT X
    FROM A
    WHERE A.id = TABLE.id
   ) AS COLUMN1,
    (
    SELECT Y
    FROM B
    WHERE B.id = TABLE.id
   ) AS COLUMN1,
   (
    SELECT Z
    FROM C
    WHERE C.id = TABLE.id
   ) AS COLUMN1,
   ...
FROM
    TABLE
WHERE
    TABLE.id = @param;

These queries do several internal sub queries from every column they return.

We are planning to rewrite these queries on the follow pattern:

SELECT
    A.X, B.Y, C.Z
FROM
    TABLE
    INNER JOIN A on A.ID = TABLE.ID
    INNER JOIN B on B.ID = TABLE.ID
    INNER JOIN C on C.ID = TABLE.ID
WHERE
    TABLE.id = @param;

With inner joins they are easier to read and understand, but is it really any faster? Is it the better way to write them?
Unfortunately the first one we rewrote didn’t improve the query time, it made the query a bit slower.

Here is my question: should we rewriting all these queries? Are these sub-queries a good way to do this job? Are they faster the the inner-join way?

  • 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-05-19T23:51:46+00:00Added an answer on May 19, 2026 at 11:51 pm

    If I understand your question correctly, you are starting an operation to rewrite some of your SQL statements because you THINK there might be an issue with them.

    My advice is to stop and first start to determine where your time is currently being spent.
    Only after you have found that it’s in the queries with those scalar subselects AND it’s because of those scalar subselects, you should be rewriting them.
    Until then: start tracing and examining.

    Here are two threads from OTN that are used to guide people with performance problems:

    http://forums.oracle.com/forums/thread.jspa?messageID=1812597
    http://forums.oracle.com/forums/thread.jspa?threadID=863295

    Regards,
    Rob.

    And: because of scalar subquery caching, your original query might be a lot faster than a rewritten query using joins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been tasked to read in some data from some weird old system.
I've imported an old guestbook into drupal, but some smilies from old system will
I have a library, and I want to migrate it from an old system
I inherited a database from an old system we have, in which (among other
I have some legacy DB with many tables (around 100) the old system is
In our old system, we used YUI, but the new one is using jQuery.
Basically I have a export from an old system with timesheets in it. Each
In our old system we had pages rendered from XSLT. In order to change
I have an old system that uses XML for it's data storage. I'm going
I have a quite old templating system written on top of ERB. It relies

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.