72% Cost Reduction in This SQL With Two Small Changes

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024

ความคิดเห็น • 9

  • @matrixevo88
    @matrixevo88 17 วันที่ผ่านมา +1

    Thank you for the tip at 3:42 about checking all columns from the joined tables to see where values differ. I have been plagued with unexplained duplicate rows and would use DISTINCT or UNION (as opposed to UNION ALL) as a coverup, but it never sat right with me to do that. I can't wait to try out your suggestion!

    • @DatabaseStar
      @DatabaseStar  14 วันที่ผ่านมา

      Glad to hear it helped! It's a helpful tip and I hope you can try it out soon.

  • @higiniofuentes2551
    @higiniofuentes2551 9 หลายเดือนก่อน

    Thank you for this very useful video!

    • @DatabaseStar
      @DatabaseStar  9 หลายเดือนก่อน +1

      Glad it was helpful!

  • @higiniofuentes2551
    @higiniofuentes2551 9 หลายเดือนก่อน

    Your suggestion here is to check any query where distinct is involved?
    I think a list of critical/suspicious instructions will be great!
    Thank you!

    • @DatabaseStar
      @DatabaseStar  9 หลายเดือนก่อน +2

      Yeah that's right. Sometimes the distinct keyword is necessary, but sometimes it's not needed and is hiding another issue.

  • @soumitrasarkar
    @soumitrasarkar 9 หลายเดือนก่อน

    I’m sorry, how is this helpful? You’ve initially had a query where not all the joins were necessary and then you have essentially removed the unnecessary joins to reduce costs. What was causing the cost in the first place was a poor query. There is no inherent optimization on how the data is being pulled.

    • @DatabaseStar
      @DatabaseStar  9 หลายเดือนก่อน

      Thanks for the feedback. That's the point of the video - there are sometimes changes you can make to remove things from the query that aren't necessary, which improves performance.

    • @soumitrasarkar
      @soumitrasarkar 9 หลายเดือนก่อน

      Got it! Thank you for explaining. And if the goal is to warn users to check their queries before running, that makes total sense. I think I was misled by the title, assuming that there are some inherent changes you can make to the queries/joins or re-writing them in a particular order to get the same results but lower costs. Thank you for clarifying.