@Gonsalu Uploading directly from Plan Explorer? Not heard of that issue before.
@Gonsalu However you like. Some people put the XML on a file-sharing site. Whatever's easiest. I generally recommend the Plan Explorer route because it avoids that issue (normally - not sure what's going on in your case).
At this stage I'd just say post the thing somewhere so we can get a look, I don't care much where tbh.
I did think of one way a hint would affect plan selection - hints in some versions prevent simple parameterization and go on to full optimization where a trivial plan isn't available. Probably not the cause in your case, but it is one scenario.
@Gonsalu The queries are semantically different due to the confused approach with table aliases. Your NOLOCK query aliases both tables as I. The other query aliases only one as I. Write queries with explicit and clear aliasing to prevent unexpected results.
Right. I prefer to use different aliases and to qualify every reference. Avoids these sorts of easy-to-make mistakes, and makes reading the thing easier IMHO.
Interesting query. All else being equal, each of the GROUP BY grouper_field calls into CROSS APPLY should result in the same X record, which then gets... displayed once (MAX should arbitrarily be selecting from replicas of the same row)... (from my quick inspection)
@Gonsalu That's the distinction. If we were going purely by the query plan costs (which you should never put too much weight into) and line up all the options so far, that last option shows the least cost from adding the percentages
@Gonsalu The ROW_NUMBER often comes out on top because it only scans the index once. The APPLY can be faster when a distinct list of keys is available without doing an explicit DISTINCT (e.g. where the keys exists in another table) and the inner side of the correlated join is optimally indexed, and where there a relatively few, large groups.
To be honest, for day to day usage, I only use ROW_NUMBER for Top-N-Per-Group queries; it performs well for typical use cases and rarely if ever performs the worst.
@ypercube I can see how that might be abused horribly, but it may also be legitimate. It's not much different to having stored procedures and changing them dynamically?
Hi. Is the sql server full-text indexing process quick or does it take time to create the indexes? If its the second case how to we know its completely built?
@ypercube I can't see how you would change the running code in the interpreter with it. You would still have to import the module somehow and you can just do that off the filesystem anyway.