Performance Troubles - Function on Date Variable - SQL in Sixty Seconds 192

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

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

  • @PinalDaveSQLAuthority
    @PinalDaveSQLAuthority  3 ปีที่แล้ว

    Here are the videos discussed in the video:
    Optimize DATE in WHERE Clause th-cam.com/video/GGwfJ3Sj6a0/w-d-xo.html
    Performance: Between and Other Operators th-cam.com/video/AL1AQrta1-Q/w-d-xo.html

  • @ItsWithinYou
    @ItsWithinYou 2 ปีที่แล้ว +1

    Excellent! Many thanks for sharing your experience!

  • @gurrrn1102
    @gurrrn1102 2 ปีที่แล้ว +2

    My thought was that BETWEEN is logically equivalent to (and parsed as) >= and

  • @adithyaravishankar
    @adithyaravishankar 3 ปีที่แล้ว +1

    Man, yet another gem of a video. Thank you.

  • @AlAshcroft
    @AlAshcroft 3 ปีที่แล้ว +1

    I think this is misleading though - between includes the lower and upper ranges. So it is the same as saying ModifiedDate > '2011-06-15' and ModifiedDate

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  3 ปีที่แล้ว

      Yes between agrees both the edges but the issue in this video is with the DATEADD which creates more problems.

  • @logu50
    @logu50 2 ปีที่แล้ว +1

    Hello Pinal sir, thanks for your valuable videos. I have an one doubts, for the primary key perspective which one is best either INT or UNIQUEIDENTIFIER . Kindly suggested me. Thanks

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  2 ปีที่แล้ว

      Int in most cases.

    • @logu50
      @logu50 2 ปีที่แล้ว +1

      @@PinalDaveSQLAuthority Thanks for your reply. But security wise INT type is advisable ?

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  2 ปีที่แล้ว +1

      @@logu50 I do not see any issue with security wise... what issue do you see in terms of security.

  • @asutosh_nayak
    @asutosh_nayak 2 ปีที่แล้ว +1

    Hello Sir,
    I have a question. How to find atleast, atmost things from a table.
    E.g. Write a query to find out the managers who is having atleast 10 employees? All the employees and managers belong to a sing table emp.

  • @Eclipce051
    @Eclipce051 3 ปีที่แล้ว +1

    A coworker had this same issue. This person had the query giving data inconsistent with the production data.

  • @juanandrew1356
    @juanandrew1356 2 ปีที่แล้ว +1

    I have a little issue with my system.
    I need to calculate COGS (Cost of Goods Sales) of particular Item everytime the user posted a transaction.
    The problem comes when the data gets too many.
    I have to:
    1. Find the last cost of the Item according to Date
    2. Update the COGS of the Item in that transaction
    3. Reupdate the COGS of the Item in next transaction if there are any.
    These query is so expensive.
    I dont know how to improve it

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  2 ปีที่แล้ว +1

      This requires detailed discovery of your system.

    • @juanandrew1356
      @juanandrew1356 2 ปีที่แล้ว

      @@PinalDaveSQLAuthority query, system spec, database spec?

  • @carlosbolivar3508
    @carlosbolivar3508 3 ปีที่แล้ว +1

    Do you have any video to compare the performance of GROUP BY vs DISTINCT ?

  • @gabtug
    @gabtug 3 ปีที่แล้ว +1

    Would casting the column as date slow performance? Or is engine smart enough to know date is a shortened datetime? If so then you could safely use between... Ie something like cast(OrderDatetime as date) between date1 and date2

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  3 ปีที่แล้ว

      Casting does not slow down anything in this scenario. You may try out with similar example.

  • @alonzohessjr
    @alonzohessjr 3 ปีที่แล้ว +1

    Thank you for the excellent tip.

  • @nikunjkelatkar3282
    @nikunjkelatkar3282 2 ปีที่แล้ว +1

    Hi sir my Database getting slow everyday and when I check the session log I find sp_OAMethod process count is more which impact the database performance how can I resolve this issue please suggest !

  • @pareshyadnik4108
    @pareshyadnik4108 3 ปีที่แล้ว +1

    Hello pinal sir..thanks for the valuable video's.. currently I am preparing for SQL interview and got stuck at below question..
    1: explain execution plan
    2: how to optimise SQL query\ store procedure
    Can you tell me how I can answer these questions

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  3 ปีที่แล้ว

      All the best for interview. Many of this questions are answered in my blog blog.sqlauthority.com just search there.

  • @mrgogate
    @mrgogate 3 ปีที่แล้ว

    this is great.. but why would between fails to give correct results?

    • @AlAshcroft
      @AlAshcroft 3 ปีที่แล้ว +1

      it's not - between INCLUDES the upper range, and is therefore the equivalent of ModifiedDate

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  3 ปีที่แล้ว

      Between includes both the ranges.

  • @vishalkumargupta5484
    @vishalkumargupta5484 3 ปีที่แล้ว +1

    well explained sir.

  • @utkarshgupta2943
    @utkarshgupta2943 3 ปีที่แล้ว +1

    But performance of between is better than operators for large data set

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  3 ปีที่แล้ว +1

      Hi Utkarsh, performance of between is not better, you may check earlier videos in this series, where I explain that.