473,666 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Which query would be faster

Which would be faster a single

select * from table where part in (A12345,1FB2356 ,346C79,349872)

or multiple

select * from table where part="A12345"
select * from table where part="1FB2356"
select * from table where part="346C79"
select * from table where part="349872"
Table has 450,000 rows
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| part | char(10) | YES | MUL | NULL | |
| descr | char(9) | YES | | NULL | |
| list | decimal(7,2) | YES | | NULL | |
| trade | decimal(7,2) | YES | | NULL | |
| cost | decimal(7,2) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+


Jul 19 '05 #1
2 1641
I would have guessed on the first one.
My expericence say that one query is faster than many. *

* depends on the querystructure.

Christoph Schmitz
"Bob Van Der Ploeg" <bo*@vdpcorp.co m> wrote in message news:<es******* *************@t wister.tampabay .rr.com>...
Which would be faster a single

select * from table where part in (A12345,1FB2356 ,346C79,349872)

or multiple

select * from table where part="A12345"
select * from table where part="1FB2356"
select * from table where part="346C79"
select * from table where part="349872"
Table has 450,000 rows
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| part | char(10) | YES | MUL | NULL | |
| descr | char(9) | YES | | NULL | |
| list | decimal(7,2) | YES | | NULL | |
| trade | decimal(7,2) | YES | | NULL | |
| cost | decimal(7,2) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+

Jul 19 '05 #2
I would have guessed on the first one.
My expericence say that one query is faster than many. *

* depends on the querystructure.

Christoph Schmitz
"Bob Van Der Ploeg" <bo*@vdpcorp.co m> wrote in message news:<es******* *************@t wister.tampabay .rr.com>...
Which would be faster a single

select * from table where part in (A12345,1FB2356 ,346C79,349872)

or multiple

select * from table where part="A12345"
select * from table where part="1FB2356"
select * from table where part="346C79"
select * from table where part="349872"
Table has 450,000 rows
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| part | char(10) | YES | MUL | NULL | |
| descr | char(9) | YES | | NULL | |
| list | decimal(7,2) | YES | | NULL | |
| trade | decimal(7,2) | YES | | NULL | |
| cost | decimal(7,2) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+

Jul 19 '05 #3

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

Similar topics

9
3124
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
1
4282
by: Paul | last post by:
Assume you have two varchar (or Text) columns named L and U which are identical except that the charset for L is latin1 and the charset for U is utf8. All the records in L and U are identical in terms of content, consisting of only 7 bit ASCII characters. Both columns have indexes of the same type (e.g. assume Unique indexes if you want). Here's my question: Will the fact that column U has a utf8 charset make select queries run slower on...
2
3474
by: ruben | last post by:
Hi: I must have missed something, but how is it possible that a join on tables A and B is faster (a lot faster) than a query to one of the tables with the same conditions? The problem seems to be with the query plan, in the case os a query to table_a only, the planner executes a "Seq Scan", in the case of a join, an "Index Scan". table_a has about 4M records, so the difference is quite noticeable.
11
2131
by: 73blazer | last post by:
We are migrating a customer from Version 7.1 FP3, to Version 8.2 (8.1 FP8). For the most part, things are faster, but there is one query that is much much slower, and it is a query that is used all the time. select ATTR1,ATTR2,ATTR3,ATTR4 from physical.part_list where S_PART_NUMBER like '%KJS%' The widlcard before and after seems to be hosing it, but for this particular piece of the application, this type of query is neccessary.
1
2436
by: Danny Dy | last post by:
Hi To All, I always write My VBA code in SQL(see Example). Private Sub cbxAEName_NotInList(NewData As String, Response As Integer) Dim stSQL as String Dim strMsg As String strMsg = "'" & NewData & "' is not an available AE Name " & vbCrLf & vbCrLf
3
2055
by: mathilda | last post by:
When I'm opening a recordset for add new, is it faster to put a limiting clause on it? i.e. does "Select from Where Keyfield = " & value & " return a recordset faster than "Select from "
2
2168
by: thomson | last post by:
Hi all, can any one tell me which is fast traversing a XML file or a hash file is fast, i got few few field names and values in XML which i will use to retrieve. I can use Hash File also to do the same operation, Can any one tell me which is faster. Thanks in Advance
2
2627
theGeek
by: theGeek | last post by:
I always wonder which one of join or subquery should I be using to solve a particuar problem so that I get the correct result set in minimum time. It usually happens that I can write a query quickly using subqueries (I think I happen to think that way more easily than join way :)) but I see others making use of joins all the time. May be that they can think of a query more easily using joins. I am saying that because I don't usually see much of...
10
3152
by: Ian | last post by:
Henry J. wrote: MDC *guarantees* clustering, whereas a table with a clustering index will eventually require maintenance (a.k.a. reorg) to maintain the cluster ratio. That's not to say that a clustering index isn't still valuable (especially for high cardinality columns that aren't a reasonable candidate as an MDC dimension).
1
8556
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8642
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4371
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2774
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.