locked
Improve aggregate query in SQL RRS feed

  • Question

  • User-1256377279 posted

    Hi Guys,

    Basically i want to improve the below SQL query performance currently it take 5 sec for 109 records, the total record in actual table is 11000.

    select  DailyDate,ShortDate, SUM(DailyTotalCases), SUM(DailyTotalDeaths),SUM(DailyNewCases),SUM(DailyNewDeaths) from [vw_dash_ch]
    GROUP BY DailyDate,ShortDate

    Thanks for your help

    shabbir

    Friday, April 17, 2020 12:22 PM

Answers

  • User303363814 posted

    Do you have an index on DailyDate,ShortDate?

    CREATE INDEX ForGrouping ON vw_dash_ch (DailyDate, ShortDate)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 18, 2020 12:40 AM
  • User288213138 posted

    Hi shabbir_215,

    Basically i want to improve the below SQL query performance

    As PaulTheSmith's said, you can try to use the CREATE INDEX statement to create indexes in tables.

    Indexes are used to retrieve data from the database more quickly than otherwise. The users cannot see the indexes, they are just used to speed up searches/queries.

    CREATE INDEX index_name
    ON table_name (column1, column2, ...);

    more information about the use of CREATE INDEX you can refer to this link:

    https://www.w3schools.com/sql/sql_create_index.asp

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 18, 2020 7:26 AM

All replies

  • User303363814 posted

    Do you have an index on DailyDate,ShortDate?

    CREATE INDEX ForGrouping ON vw_dash_ch (DailyDate, ShortDate)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 18, 2020 12:40 AM
  • User288213138 posted

    Hi shabbir_215,

    Basically i want to improve the below SQL query performance

    As PaulTheSmith's said, you can try to use the CREATE INDEX statement to create indexes in tables.

    Indexes are used to retrieve data from the database more quickly than otherwise. The users cannot see the indexes, they are just used to speed up searches/queries.

    CREATE INDEX index_name
    ON table_name (column1, column2, ...);

    more information about the use of CREATE INDEX you can refer to this link:

    https://www.w3schools.com/sql/sql_create_index.asp

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 18, 2020 7:26 AM
  • User-1256377279 posted

    Thanks i will try it

    Shabbir

    Saturday, April 18, 2020 9:29 AM