473,473 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
Create 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_condition AND B_where_condition
LIMIT 0,20
Assuming:

A contains 1,000,000 records and B contains around 4,000,000 records,
and
the A_where_condition will retrieve 300,000 rows from A
the B_where_condition will retrieve 100,000 rows from B
and
altogether, the where_conditions 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_condition 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_condition, 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 1459
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
by: Davey | last post by:
Which is typically faster - a Java server application or a C++ server application?
6
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...
4
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...
12
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...
22
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...
0
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....
17
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...
40
by: kavi | last post by:
Hello friends, Could any one tell the way of calculating the speed of c program execution?
1
by: jason.teen | last post by:
Hi, I have these two tables: codes_together ---------------------------------------------- Prod_Name | CODE ---------------------------------------------- Cats BOB CAT...
1
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...
0
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,...
0
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...
0
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...
1
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...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.