How do SQL Recursive CTE queries work

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • In this video, you are going to learn how SQL Recursive CTE queries work.
    This video is part of my HIgh-Performance SQL video course, so if you liked this video, you are going to love my video course.
    vladmihalcea.com/courses/high...
  • НаукаНаука

Комментарии • 7

  • @dschulzg
    @dschulzg 2 года назад +1

    Excellent content. Very well explained. Thanks Vlad!

    • @vladmihalcea
      @vladmihalcea  2 года назад +1

      Thanks, Diego. There are more to come.

  • @gssj-o8p
    @gssj-o8p 8 месяцев назад +1

    Nice explanation!

    • @vladmihalcea
      @vladmihalcea  8 месяцев назад +1

      Thanks. This video is a lesson from my HIgh-Performance SQL video course, so if you liked it, you are going to love the video course.
      vladmihalceastore.teachable.com/p/high-performance-sql-online?coupon_code=BLACKFRIDAY23

  • @phuphan2513
    @phuphan2513 Год назад +1

    Hi Vlad, thanks for your video. May I have several questions as below:
    1. why when the first statement "select 0,0" executed, then these 0,0 sent to i, and consecutive_sum? while the whole statements within "With" haven't finished yet?
    2. IN the second statment i.e. recursive statement "select i + 1, i + 1 + consecutive_sum from consecutive_sum_number" And when i + 1, i+1 + consecutive_sum will be sent to i, and consecutive_sum again for the next iteration?
    In short, it doesn't look like a native recursive isn't it? cause it doesn't seem to be function call same function, so everytime when consecutive_sum is call then within this function we have select 0,0, union with something. it quite confused me.
    Thank you

    • @vladmihalcea
      @vladmihalcea  Год назад +1

      SQL is a declarative language. You're analyzing the query definition using a procedural mindset. That's why it confused you.
      What you need to do is run EXPLAIN ANALYZE on the query and see exactly the stream operations done by the DB when executing the query.

    • @phuphan2513
      @phuphan2513 Год назад +1

      @@vladmihalcea Thanks Vlad, will try to explore more. anyway subcribed to your channel to see more useful contents.