Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Posts
    57

    Unanswered: SQL problem: optimizing UNION operator

    Hello!
    My application's search is based on some queries grouped by union operator.
    My problem is that I would like to optimize the search and I cannot optimize the UNION operator.
    If I add the times of all the queries I get a number infinitely small than the time obtain by the reunion or intersection of these queries.
    For example, if I have:
    select 1
    union
    select 2
    union
    select 3
    etc.

    If I add the select1, 2, 3 etc. response time I will get a very small result comparing with the union (Intersect by the use of exists) result time. I cannot use union all because I need to eliminate the duplicates.
    Can you give me an advice regarding this optimizing problem?
    Thanks in advanced.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    what does "Intersect by the use of exists" mean?

    if you want existence, use the EXISTS operator with a subquery
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •