473,608 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Seperate or Combined, the speed consideration

To help making indexes & planning the table constructions & writing SQL
statements correctly and effectively, I am thinking about how the SQL server
actually implements a table join query.

------------------------------------------------------
For Example:

A: person names, B: products each person has, products could be thourands of
kinds, table B stores the product IDs only.

SELECT something FROM A INNER JOIN B ON A.id=B.id
WHERE A_where_conditi on AND B_where_conditi on
LIMIT 0,20
Assuming:

A contains 1,000,000 records and B contains around 4,000,000 records,
and
the A_where_conditi on will retrieve 300,000 rows from A
the B_where_conditi on will retrieve 100,000 rows from B
and
altogether, the where_condition s can give a result of, let's say: 2,000
rows

-----------------------------------------------------
Let's see how MySQL will treat this query:

According to the MySQL manaul, MySQL will firstly set table A to be
dependent on table B, cos table B gives less rows than A.
It will:

1. use B_where_conditi on to retrieve that 100,000 rows from B and fully load
them into memory.
2. then join A onto it the loaded temp table in memory.

---NOTE.
2.a. Dont know when it will use the A_where_conditi on, during the join
process or after the join? However it is the matter of MySQL itself, not the
point I am trying to figure out.
2.b. Dont know how MySQL will use the LIMIT contidion, during the join
process or after the join finished? I mean if it counting the rows joined
into the temp table, and after (with or without the word DISTINCT) 20 rows
have being retrieved, the query finish? I guess so but not sure.
3.c If there is an ORDER BY, how to set the index and/or pre-sort the
physical stored datas to avoid MySQL from loading the whole table A and
re-sorting the results before the LIMIT applies?

As the discussion above, I think the JOIN action gonna cost a lot because
the table was seperated, and MySQL will forced to load one of them fully
(under the where_condition ). If they are not seperated but one single table,
this will not happen.

Seperated table give the advantage of unlimited number of products each
person can has. But if use a single table, have to limit the number of
products of each person.

Anyone got any idea? Am I right or wrong here?

Thx.

ccton

Jul 19 '05 #1
3 1475
Well I said thourands of kinds of products, which means you can not set a
single column with SET data type, that can contains a collection of 64
items.

So it seems to use columns like:

product1, product2,... in table A if want to use a single table and get high
preformance.
:-)

or a stupid way like column SET1,SET2,...

haha... 100 columns can contain a collection of 6400 products... impossible
to be done like this!
Jul 19 '05 #2
Well I said thourands of kinds of products, which means you can not set a
single column with SET data type, that can contains a collection of 64
items.

So it seems to use columns like:

product1, product2,... in table A if want to use a single table and get high
preformance.
:-)

or a stupid way like column SET1,SET2,...

haha... 100 columns can contain a collection of 6400 products... impossible
to be done like this!
Jul 19 '05 #3
Well I said thourands of kinds of products, which means you can not set a
single column with SET data type, that can contains a collection of 64
items.

So it seems to use columns like:

product1, product2,... in table A if want to use a single table and get high
preformance.
:-)

or a stupid way like column SET1,SET2,...

haha... 100 columns can contain a collection of 6400 products... impossible
to be done like this!
Jul 19 '05 #4

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

Similar topics

19
3186
by: Davey | last post by:
Which is typically faster - a Java server application or a C++ server application?
6
11138
by: Jazper Manto | last post by:
hi i'm looking for a speed test of c# vs. c++. the test should be representative for mass data production. it should also include IO operations. can anybody give me a good link from the internet? thanx jazper.
4
1359
by: Joanna Carter \(TeamB\) | last post by:
Hi gurus. Does anyone have any experience as to whether .NET 2.0 will be any faster executing than .NET 1.1 ? We are looking at starting a new project in .NET and are getting feedback from other developers that they have found problems with apparent speed of apps being slower than their clients were expecting having come from Win32 Delphi apps.
12
26858
by: chipgraphics | last post by:
:confused::confused: I have been on the quest to find a php script that can serve files for downloads and limit the speed at which the file is transfered to the user. I want a faster download speed for registered members and a slower speed for guests. The only other thing I can think of is using the header() function to force a download for the requested file type and stream the file to the user's browser. Then using sleep() or usleep()...
22
2000
by: Annajiat | last post by:
Hi, a) int grid; Which of the following is faster? 1. memset(grid,0,1010*1010); 2. memset(grid,0,sizeof(grid)); b) Is there any faster alternative to initializing memory? c) What is the difference between comp.lang.c and alt.comp.lang.c ?
0
1170
by: Steve Holden | last post by:
EWT LLC and CCP h.f., having specific commercial interests in doing so, have decided to sponsor a sprint on the Python programming language with specific short- and medium-term acceleration goals. The sprint is also intended to stimulate broad consideration of the future of Python, and specifically to try and identify the most promising routes to improved performance. Selected members of the Python developer community will receive
17
2502
by: sloank | last post by:
anyone know how to set up a 'speed bump'. once someone clicks on an external link on my website, I want a page to come up that says you are leaving my site, with an OK button. once the OK button is clicked I want to go to the original link that was clicked on. any ideas.
40
2955
by: kavi | last post by:
Hello friends, Could any one tell the way of calculating the speed of c program execution?
1
1360
by: jason.teen | last post by:
Hi, I have these two tables: codes_together ---------------------------------------------- Prod_Name | CODE ---------------------------------------------- Cats BOB CAT Wabbbits BUNNY & BUGS
1
1573
by: _thedebugger | last post by:
Dear Friends, We are developing one wbesite in visual studio 2005 and sql server 2000. now my question is I want to seperate some modules on the website. Like 1. there will be few sections, like general listing of winners and users and other products. 2. Game Play Panel, Where user will use their username and password and credit card details and play the game.
0
8063
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8498
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8152
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
8341
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
3962
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
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2474
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
1
1598
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1331
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.