PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > order of operations
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
order of operations

Réponse
 
LinkBack Outils de la discussion
Vieux 18/12/2007, 19h54   #1
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut order of operations

i think i need a refresher. if i have this:

SELECT SomeColumn
FROM SomeTable
JOIN
(
SELECT AnotherColumn
FROM AnotherTable
WHERE OneColumn = 'A Value'
) DerivedTable
ON DerivedTable.AnotherColumn = SomeColumn

then i'm writing a cartesian statement? meaning that for each record in
SomeTable causes DerivedTable to be run *every* time the join comparision is
made? i had thought that nested statements get executed first, and the
results cached as a temporary table. i had thought that the operation done
in the join at that point was in the same fashion as if both tables were
permanent. i hope that makes sense.

the other thing i've been told is that derived tables carry no indexing
which makes the join take longer to complete. is it possible to use indexes
on such derived tables, if this is true, so that i get better performance
when joining them to other resultsets?

what is correct? and, would you provide a resource that goes into the order
of these operations in detail?

tia,

me


  Réponse avec citation
Vieux 18/12/2007, 21h31   #2
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: order of operations

Steve wrote:
>i think i need a refresher. if i have this:
>
> SELECT SomeColumn
> FROM SomeTable
> JOIN
> (
> SELECT AnotherColumn
> FROM AnotherTable
> WHERE OneColumn = 'A Value'
> ) DerivedTable
> ON DerivedTable.AnotherColumn = SomeColumn
>
> then i'm writing a cartesian statement? meaning that for each record
> in SomeTable causes DerivedTable to be run *every* time the join
> comparision is made? i had thought that nested statements get
> executed first, and the results cached as a temporary table. i had
> thought that the operation done in the join at that point was in the
> same fashion as if both tables were permanent. i hope that makes
> sense.
> the other thing i've been told is that derived tables carry no
> indexing which makes the join take longer to complete. is it possible
> to use indexes on such derived tables, if this is true, so that i get
> better performance when joining them to other resultsets?
>
> what is correct? and, would you provide a resource that goes into the
> order of these operations in detail?
>
> tia,
>
> me


Why are you not just joining?


  Réponse avec citation
Vieux 18/12/2007, 21h47   #3
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: order of operations


"Paul Lautman" <paul.lautman@btinternet.com> wrote in message
news:5sqsgiF1albnoU1@mid.individual.net...
> Steve wrote:
>>i think i need a refresher. if i have this:
>>
>> SELECT SomeColumn
>> FROM SomeTable
>> JOIN
>> (
>> SELECT AnotherColumn
>> FROM AnotherTable
>> WHERE OneColumn = 'A Value'
>> ) DerivedTable
>> ON DerivedTable.AnotherColumn = SomeColumn
>>
>> then i'm writing a cartesian statement? meaning that for each record
>> in SomeTable causes DerivedTable to be run *every* time the join
>> comparision is made? i had thought that nested statements get
>> executed first, and the results cached as a temporary table. i had
>> thought that the operation done in the join at that point was in the
>> same fashion as if both tables were permanent. i hope that makes
>> sense.
>> the other thing i've been told is that derived tables carry no
>> indexing which makes the join take longer to complete. is it possible
>> to use indexes on such derived tables, if this is true, so that i get
>> better performance when joining them to other resultsets?
>>
>> what is correct? and, would you provide a resource that goes into the
>> order of these operations in detail?
>>
>> tia,
>>
>> me

>
> Why are you not just joining?


this is a sample. i'm troubleshooting a very lengthy query i wrote that is
now having performance issues - the number of rows is very large now.
anyway, this is an example of a situation.

i finally found the answer in the mysql manual after much digging. i was
correct. there are two general subquery types, correlated and uncorrelated.
the example i posted was uncorrelated as no part of the subquery references
a column of the outter query. in that case, "mysql executes uncorrelated
queries only once." so, i'm not loosing my mind - and the dba's at the web
hosting company can kiss my ass for telling me different...and for saying
that derived tables are unindexed. in, any, some, etc. specifically look for
indecies that can be used in look-up type statements.

i'd have almost wished i was wrong though, as then i'd be further along in
solving my actual problem.


  Réponse avec citation
Vieux 19/12/2007, 14h37   #4
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: order of operations


"Steve" <no.one@example.com> wrote in message
news:aeX9j.1345$Jh1.416@newsfe02.lga...
>
> "Paul Lautman" <paul.lautman@btinternet.com> wrote in message
> news:5sqsgiF1albnoU1@mid.individual.net...
>> Steve wrote:
>>>i think i need a refresher. if i have this:
>>>
>>> SELECT SomeColumn
>>> FROM SomeTable
>>> JOIN
>>> (
>>> SELECT AnotherColumn
>>> FROM AnotherTable
>>> WHERE OneColumn = 'A Value'
>>> ) DerivedTable
>>> ON DerivedTable.AnotherColumn = SomeColumn
>>>
>>> then i'm writing a cartesian statement? meaning that for each record
>>> in SomeTable causes DerivedTable to be run *every* time the join
>>> comparision is made? i had thought that nested statements get
>>> executed first, and the results cached as a temporary table. i had
>>> thought that the operation done in the join at that point was in the
>>> same fashion as if both tables were permanent. i hope that makes
>>> sense.
>>> the other thing i've been told is that derived tables carry no
>>> indexing which makes the join take longer to complete. is it possible
>>> to use indexes on such derived tables, if this is true, so that i get
>>> better performance when joining them to other resultsets?
>>>
>>> what is correct? and, would you provide a resource that goes into the
>>> order of these operations in detail?
>>>
>>> tia,
>>>
>>> me

>>
>> Why are you not just joining?

>
> this is a sample. i'm troubleshooting a very lengthy query i wrote that is
> now having performance issues - the number of rows is very large now.
> anyway, this is an example of a situation.
>
> i finally found the answer in the mysql manual after much digging. i was
> correct. there are two general subquery types, correlated and
> uncorrelated. the example i posted was uncorrelated as no part of the
> subquery references a column of the outter query. in that case, "mysql
> executes uncorrelated queries only once." so, i'm not loosing my mind -
> and the dba's at the web hosting company can kiss my ass for telling me
> different...and for saying that derived tables are unindexed. in, any,
> some, etc. specifically look for indecies that can be used in look-up type
> statements.
>
> i'd have almost wished i was wrong though, as then i'd be further along in
> solving my actual problem.


problem solved. i had them 'up' the amount of cache alloted for keys and
such...and, here's the kicker, had them *enable* query caching. dumbasses!
hard to cache a derived table's results when the results are big...just
using RAM!!! where just one of 8 complex queries would take over 24 hours to
run, the whole ball of wax runs in just under 15 minutes!


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h40.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,81269 seconds with 12 queries