Forum Replies Created

Viewing 15 posts - 16 through 30 (of 31 total)

  • RE: Need help on query performance

    ChrisM@Work (5/25/2016)


    jc85 (5/25/2016)


    How should i post the table with data on this forum?

    How many rows do you need for ann_events_Tech_Details table?

    ChrisM@Work (5/25/2016)


    Ideally you would do this by posting a script...

  • RE: Need help on query performance

    ChrisM@Work (5/25/2016)


    jc85 (5/25/2016)


    ChrisM@Work (5/25/2016)

    Sorry my bad, missed the correlation:

    SELECT

    [date] = CAST(b.start_time AS DATE),

    [report_item] = (b.[source] + '-' + 'a.report_item'),

    [EN] = SUM(CASE WHEN b.lang = 'EN' THEN 1 ELSE...

  • RE: Need help on query performance

    ChrisM@Work (5/25/2016)

    Sorry my bad, missed the correlation:

    SELECT

    [date] = CAST(b.start_time AS DATE),

    [report_item] = (b.[source] + '-' + 'a.report_item'),

    [EN] = SUM(CASE WHEN b.lang = 'EN' THEN 1 ELSE 0 END),...

  • RE: Need help on query performance

    ChrisM@Work (5/25/2016)


    jc85 (5/25/2016)


    ChrisM@Work (5/25/2016)


    Only one clustered index per table, but the index can contain more than one column.

    "Different result" is too vague, please explain.

    Thanks, added.

    Incorrect result is returned, it is...

  • RE: Need help on query performance

    ChrisM@Work (5/25/2016)


    Only one clustered index per table, but the index can contain more than one column.

    "Different result" is too vague, please explain.

    Thanks, added.

    Incorrect result is returned, it is not the...

  • RE: Need help on query performance

    Isn't 1 clustered index is allowed per table?

    The query returned different result.

  • RE: Need help on query performance

    How should i post the table with data on this forum?

    How many rows do you need for ann_events_Tech_Details table?

  • RE: Need help on query performance

    Thanks ChrisM@Work.

    The query took quite some time to complete.

    Additional info provided in case you need it.

    ann_events_Tech_Details

    [start_time] - clustered index

    [id] - Unique, non-clustered index (PK)

    ann_ReportItem

    [source] - non-clustered index

    [call_flow_name] - non-clustered...

  • RE: Need help on query performance

    Try CAST(b.start_time AS DATE)

    instead of dateadd (dd, 0, datediff(dd , 0, b.start_time ))

    Just tried it, took longer time to complete.

  • RE: Need help on query performance

    Sergiy (5/24/2016)


    This is exactly the problem.

    Make both PK's non-clustered and create a new clustered index on [start_time].

    That's what you've got:

    WHERE (dateadd(dd,0, datediff(dd,0,b.start_time))) >= @StartDate

    AND (dateadd(dd,0, datediff(dd,0,b.start_time))) <= @EndDate

    I assume...

  • RE: Need help on query performance

    Sergiy (5/24/2016)


    jc85 (5/24/2016)


    Added start_time as Non-clustered index for table ann_events_Tech_Details.

    Make it clustered.

    Otherwise - drop it, no use of it anyway.

    Both tables already have id set as their clustered index so...

  • RE: Need help on query performance

    GilaMonster (5/24/2016)


    Start with an index on each table, columns used in the where clause first in the index key, then columns used in the group by

    Hope I understood correctly.

    Added start_time...

  • RE: Need help on query performance

    Yes, both tables do not have non clustered index.

    Will attach the actual plan what's I have access to my pc.

  • RE: Need help on query performance

    Thanks for the feedback everyone!

    The tables structure I provided earlier was a simplified version as I believed it will be sufficient, turned out I was wrong. Full table structure as...

  • RE: Need help on query performance

    The new query is slower.

Viewing 15 posts - 16 through 30 (of 31 total)