![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| e,g, Select * From TableA LEFT JOIN TableB ON xxx vs Select * From TableA JOIN TableB ON xxx Since I believe LEFT JOIN requiress less checking, so it should be faster? | |||
| Advertisements |
| | #2 | ||
| howa <howachen@gmail.com> wrote in news:1181917118.297796.294670 @i38g2000prf.googlegroups.com: > e,g, > > Select * From TableA LEFT JOIN TableB ON xxx > > vs > > Select * From TableA JOIN TableB ON xxx > > > Since I believe LEFT JOIN requiress less checking, so it should be > faster? I don't think it really matters, as long as everything is indexed properly. LEFT vs INNER vs RIGHT etc is more about being able to return important data that might have some columns with NULL or missing values; it's not really a speed decision at all. Unless this was just a purely academic question, in which case i've missed the point | |||
| | #3 | ||
| On Jun 15, 4:13 pm, Good Man <h...@letsgo.com> wrote: > howa <howac...@gmail.com> wrote in news:1181917118.297796.294670 > @i38g2000prf.googlegroups.com: > > > e,g, > > > Select * From TableA LEFT JOIN TableB ON xxx > > > vs > > > Select * From TableA JOIN TableB ON xxx > > > Since I believe LEFT JOIN requiress less checking, so it should be > > faster? > > I don't think it really matters, as long as everything is indexed properly. > LEFT vs INNER vs RIGHT etc is more about being able to return important > data that might have some columns with NULL or missing values; it's not > really a speed decision at all. > > Unless this was just a purely academic question, in which case i've missed > the point Other things being equal, JOIN is quicker. | |||
| | #4 | ||
| On Jun 15, 11:50 pm, strawberry <zac.ca...@gmail.com> wrote: > > Other things being equal, JOIN is quicker.- Hide quoted text - > Can't get your meaning? | |||
| | #5 | ||
| On Jun 15, 5:10 pm, howa <howac...@gmail.com> wrote: > On Jun 15, 11:50 pm, strawberry <zac.ca...@gmail.com> wrote: > > > > > Other things being equal, JOIN is quicker.- Hide quoted text - > > Can't get your meaning? Taking the example of the schema I posted yesterday in another thread, the following queries will both produce the same result - but the LEFT JOIN takes twice as long (although I'm not sure of the significance of that ratio): SELECT * FROM food_category fc LEFT JOIN food f ON f.id = fc.food_id; (0.034 secs) SELECT * FROM food_category fc JOIN food f ON f.id = fc.food_id; (0.017 secs) LEFT JOINS and RIGHT JOINS are syntactically identical, therefore we should expect them to take exactly the same time: SELECT * FROM food f RIGHT JOIN food_category fc ON f.id = fc.food_id (0.034 secs) However, the question is misleading because it's rare that one type of join can, with certainty, be used in place of another. In this example, it's merely accidental that both queries produce the same result set. | |||
| | #6 | ||
| On 6 16 , 12 34 , strawberry <zac.ca...@gmail.com> wrote: > However, the question is misleading because it's rare that one type of > join can, with certainty, be used in place of another. In this > example, it's merely accidental that both queries produce the same > result set. usually, inner join can be replace by left join, provided that we don't allow null value on some fields now, considering the inner and left join, since left join will always return the rows in the left table, so i believe... less cross checking => generally faster | |||
| | #7 | ||
| howa <howachen@gmail.com> wrote: > On 6 16 , 12 34 , strawberry <zac.ca...@gmail.com> wrote: > >> However, the question is misleading because it's rare that one type of >> join can, with certainty, be used in place of another. In this >> example, it's merely accidental that both queries produce the same >> result set. > > usually, inner join can be replace by left join, provided that we > don't allow null value on some fields Which is - of course - complete nonsense. First you ask the database to add filler rows (those with NULLs) and then you ask it to remove them (in WHERE). Do you really think, the database gets faster if you put some extra work on it? > now, considering the inner and left join, > > since left join will always return the rows in the left table, so i > believe... > > less cross checking => generally faster Nope. Also LEFT JOIN has to check if a matching row exists in the other table. And insert NULLs otherwise. So if the JOIN order is the same, then LEFT JOIN does the same number of lookups in the "right" table than an INNER JOIN. But once more: INNER and OUTER JOIN in general produce different results. So there is absolutely *no* point in asking which one is faster. The choice is based on the expected result anyway. XL -- Axel Schwenke, Support Engineer, MySQL AB Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/ MySQL User Forums: http://forums.mysql.com/ | |||
| Featured Websites | ||||
|
![]() |
| Tags: faster, inner, join, left, than |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Left Outer Join | Jared | Database | 0 | 07-01-2007 9:33 PM |
| left join limit 1 | Database | 7 | 07-01-2007 7:32 PM | |
| Is self-join appropriate? | Michal Stankoviansky | Database | 6 | 07-01-2007 6:38 PM |
| Left join isn't joining | Bill | Database | 7 | 07-01-2007 6:36 PM |
| WE PAY FOR YOU TO JOIN ! ! | UCE | Building An Internet Business | 0 | 05-29-2007 1:38 AM |
| Featured Websites | ||||
|