SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Need Help with reading Explain

    I need help in determining the number of rows examined when viewing the output from Explain with regards to the following query:


    select y.id, y.name, y.age
    from
    (select x.id, x.name, x.age
    from
    (select u.id, u.name, u.age
    from users u
    where u.gender = 'female'
    union all
    select u.id, u.name, u.age
    from users u
    where u.gender = 'male') as x
    group by x.age) as y
    where y.age > 20

    The number of rows from the queries using union equate to 500 rows. The number of rows read for the outer query ("x") is 60 and the rows for the outermost query ("y") is 20. What is the final number of rows read, is it: 500 x 60 x 20 (600 000 rows) or 500 + 60 + 20 (580 rows)?

    Your help in this regard would be appreciated.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    the latter
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much. Your response is appreciated.


Tags for this Thread

Bookmarks

Posting Permissions

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