Information générale
Catégorie:
Codage, syntaxe et commandes
>>Anybody know whether an SQL statement that uses multiple UNIONS is supposed to take a lot more time to execute versus issuing two or three separate SQL statement and manually joining the results?
>
>Generally speaking, no. In your case, yes.
>
>The UNION verifies each record to be only once in the result set. That means that you will never have two records with exactly the same field values (all fields) in a result set of a SELECT ... UNION ... statement.
>
>If you know that your individual results cannot include the same records or if you don't care, you can do as you said and it may be faster.
>
>But it will surely be MUCH slower if you verify record by record, field by field, as a UNION does.
>
>Vlad
>
>>I have an SQL statement that's basically 4 separate SQL's. On their own, each SQL statement takes about 3 seconds to run. But when I put them all together with the UNION clause, it takes about 2+ minutes to run instead. The output is the same whether I use the single SQL statement with UNIONS or run each of the 4 SQL statements separately and put them into a single table using something like APPEND FROM DBF("OneofMytables").
Just add the ALL adjective to the UNION and no effort will be made to remove duplicates. That will speed things up and probably work faster than 4 SELECTs and 3 APPENDs.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement