Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query with Subqueries vs individual queries

Status
Not open for further replies.

GoTerps88

Programmer
Apr 30, 2007
174
US
I have a query with about 5 subqueries I am using for counts. Some of these subqueries have an inner join or two.

I am then reading the results in a recordset on a web form.

Would this be considered as efficient or more than opening 5 queries with 5 recordsets and displaying results on the form. These individual queries would have their own inner join or two.

My hunch is that the one inclusive query would represent better performance, but I'd like to hear other thoughts.
 
Mufasa's 1st Rule said:
One test is worth 100 expert opinions.
First, in SQL*Plus:
Code:
set timing on
Then run both versions of the code, and post the results here.


[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Great idea...

Except that doesn't account for opening and closing recordsets on the client side, which in all probability would account for a sizeable chunk of the processing. I guess I could run similar type performance testing.
 
Then in addition to "SET TIMING ON", you could also (on the client side) "SET TIME ON" for an approximation of the elapsed clock time for each query (including recordset opening/closing and network latency).

Let us know,

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
So far the results have supported using the query containing subqueries over individual queries. The larger query ran nearly as fast as one individual query. We're talking milliseconds if that of a difference.

However this was working with a limited number of records. I will next run a test on a larger recordset.
 
Cool. We'll be interested in how things go with that.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top