473,587 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

about efficiency(reph rased)

hi,All

could you tell me which case is more efficiency?(my tables have no index)
And does it has any else case more efficiency?

case1:

"select sum(Invoice_Pro duction.Quantit y) from Invoice_Product ion,(select
[dat_Item].ItemCode from [dat_Item],(select [dat_MachineType].MachineTypeID
from [dat_MachineType]"&subQuery& ") as T3 where [dat_Item].MachineTypeID =
T3.machinetypei d) as T1,(select [Invoice].InvoiceNo from Invoice,(select
[users].user_id from [users] where [Users].User_ID = '"& rs2(0) &"') as T4
where T4.User_ID = invoice.dealern o and Invoice.Cyear >= "&startYear &" and
Invoice.Cyear <= "&endYear&" and Invoice.Cmonth >= "&startMont h&" and
Invoice.Cmonth <= "&endMonth& ") as T2 where invoice_product ion.ItemCode =
T1.ItemCode and T2.invoiceno = invoice_product ion.invoiceno"

case2:

"select sum(Invoice_Pro duction.Quantit y) from
[Invoice_Product ion],[Invoice],[dat_MachineType],[dat_Item],[users] where
[users].user_id = [invoice].DealerNo and [dat_Item].ItemCode =
[Invoice_Product ion].ItemCode and [dat_Item].MachineTypeID =
[dat_MachineType].MachineTypeID and [Invoice_Product ion].InvoiceNo =
[Invoice].InvoiceNo and [Users].User_ID = '"& rs2(0) &"' and Invoice.Cyear
>= "&startYear &" and Invoice.Cyear <= "&endYear&" and Invoice.Cmonth >=
"&startMont h&" and Invoice.Cmonth <= "&endMonth& ""

Thanks for any help

Yicong
Sep 21 '06 #1
2 1191
yicong wrote:
could you tell me which case is more efficiency?(my tables have no index)
Add some indexes!
And does it has any else case more efficiency?
I would write it as follows, for clarity:

select sum(Invoice_Pro duction.Quantit y)
from [Invoice_Product ion]
join [Invoice] on [Invoice].InvoiceNo = [Invoice_Product ion].InvoiceNo
join [users] on [users].user_id = [invoice].DealerNo
join [dat_Item] on [dat_Item].ItemCode = [Invoice_Product ion].ItemCode
join [dat_MachineType] on [dat_MachineType].MachineTypeID =
[dat_Item].MachineTypeID
where [Users].User_ID = '"& rs2(0) &"'
and Invoice.Cyear between "&startYear &" and "&endYear&"
and Invoice.Cmonth between "&startMont h&" and "&endMonth& "

Also, you can remove dat_Item and dat_MachineType entirely (unless you
might have null values with non-zero quantities, and want to exclude
those from the total).
Sep 21 '06 #2
yicong (ci*******@163. com) writes:
could you tell me which case is more efficiency?(my tables have no index)
And does it has any else case more efficiency?
Why not benchmark instead? Without access to the data, it's difficult
to say what is going to happen.

Anyway, without indexes nothing will be effecient.

Furthermore you should not interpolate parameter values into the string
but use parameterised commands instead, not the least if you are interested
in performance.

I'm sorry, but I gave trying to understand your first query when I came
to this "subquery" that I don't know what it is.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Sep 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1953
by: Jeffrey Borkent | last post by:
Hi There, Please let me rephrase the problem as many people misunderstood what i was trying to ask. I know that the __init__ is the class constructor, that was not my question. under the def __init__ are several assignments
7
2539
by: S.K.Mody | last post by:
typedef unsigned long long int uint64 typedef unsigned char uint8; Class Simple { union { uint64 x; uint8 r; } public: Simple(uint64 n) : x(n) {;} //....
5
1558
by: Charles Law | last post by:
I think I asked the wrong question last time, so I am starting a separate post to distinguish them. Take five classes: ClassA and ClassW...Z ClassA raises five events: Event1...5 ClassW...Z handle some combination of these events. For example ClassW handles Event1, 2 and 5
5
1448
by: TC | last post by:
I have a VB.Net application which uses System.Data.OleDb to connect to a Jet database. Recently, I learned that MDAC no longer contains Jet drivers. I'm confused what that means for my application. Can someone help me with answers to these basic questions? First of all, does the absence of Jet driver from MDAC imply that most computers in...
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.