This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Options for a Subquery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Options for a Subquery" Watch "Options for a Subquery" New topic
Author

Options for a Subquery

amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Hello,
I have read that subqueries perform much slower. I would like to know what are the other options available we can consider instead of using subqueries. I have seen 80% subqueries in the Stored procedures which I am accessing in Java.
I remember once we had used Temp table approach to reduce this usage. I am not an expert in Database but occasionally need to write some queries and Stored procedures.

Thanks,
Amit


Regards,
Amit
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

Before diving off into alternatives, perhaps it would be best to ascertain that sub-queries are actually a problem? Just reading it somewhere doesn't mean it's a real issue, and even if they are in certain circumstances, it's best to verify that something is an actual problem in your environment before flying off the handle.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Hi Bear,
Thanks for your reply. I agree with whatever you have said. I just wanted to know whether this kind of topic is available in the HF SQL.
Thanks once again,
Amit
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Poorly written queries always perform poorly.

Sub-queries are a necessary part of set processing. Learning to write quality queries entails you learn how to write effective sub-queries.
Lynn Beighley
author
Ranch Hand

Joined: Sep 12, 2007
Posts: 82
In HF SQL, we deal with presenting some subqueries as joins, and vice versa, but do not offer an opinion on the difference in performance.


Lynn Beighley<br />Author, Head First SQL
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Options for a Subquery
 
Similar Threads
Java & Oracle Stored Procedures
Spring :Approach to call Stored Procedures
Calling stored procedures from EJB using JPA, is this possible ?
hibernate and stored procedures
DB2 Stored procedures written in Java