If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > question about query speed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-09-09, 23:01
dzdrazil dzdrazil is offline
Registered User
 
Join Date: Jun 2009
Posts: 2
Question question about query speed

Say I need to store information about the types of planes a user has. for each plane, I need to store 6 different numbers (average crew size, fuel used per flight, etc). There may be hundreds of customers, with perhaps no more than 5 to 10 plane types each.

which would be faster to query-joining a 3 column table (plane_ID, varName,varValue) with X rows per customer, or a 7 column table (plane_ID, aveCrewSize,...) with 1 row per customer?

Thanks all!

I've heard that disk-seek per row is the biggest bottleneck, but on small test tables the first was faster than the second, even after the queries were cached
Reply With Quote
  #2 (permalink)  
Old 06-10-09, 00:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by dzdrazil
... plane_ID, varName,varValue...
this is known as EAV -- entity-attribute-value -- and is a dangerous design

don't do it
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-10-09, 03:42
dzdrazil dzdrazil is offline
Registered User
 
Join Date: Jun 2009
Posts: 2
thanks!

is it dangerous because it's slow/ sloppy design?

Here's the main reason why I'm still asking:

Part of what I'm doing is turning an Excel spreadsheet model into a database for an online application, and the spreadsheet is practically complex enough to be sold as a product on its own. As such, there's a lot of table-within-a-table stuff that's making me want to just put a bajillion tables in the database and use JOINs everywhere (which I understand is also bad for overhead). Would it be better to have a single table of constants or is removing constants not really a beneficial normalization? I'm stuck in MyISAM b/c this is on a shared host, so I don't really have the benefit of foreign keys or such things.

PS- I saw the Entity-Attribute-Value initially when reading a book on designing a site using the Zend Framework for PHP- I guess books aren't all that reliable after all
Reply With Quote
  #4 (permalink)  
Old 06-11-09, 13:59
alexsqlforums alexsqlforums is offline
Registered User
 
Join Date: Jan 2009
Location: NYC
Posts: 11
Can a user have more than 1 plane?
Then use 2 tables

table1 = (userid,planeid)
table2 = (planeid, 7columns)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On