Skip to main content
Post Reopened by Paul White
Incorporated comments
Source Link
Paul White
  • 90.3k
  • 30
  • 424
  • 663

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we updated the server, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Here are the server changes:

  • The compatibility level was updated from 2008 to 2016, thus the cardinality estimator changed.
  • SQL Server edition was updated from Standard to Enterprise.
  • SQL Server version (2016) was not changed.
  • The storage (SSD) was not changed.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I uploadedwas not able to reproduce the same bad query plans forfrom my previous production issues (the bad query plans happen randomly), but I was able to generate similar query plans using a new simple query. I uploaded plans for the simple query without hint and with hint.

OPTION (RECOMPILE) could solve the issue. But it does not ensure that the new query plan will be better or that SQL Server will not switch to another query plan in a few days. I am not looking for a way to improve one particular query or to improve one particular query plan. I want to globally prevent Clustered Index Scan on my table.

I have many queries that query many different columns and I cannot include all columns in all indexes.

One global option that would probably solve my issues is to use the legacy cardinality estimator, but I hope to find something better.

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we updated the server, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Here are the server changes:

  • The compatibility level was updated from 2008 to 2016, thus the cardinality estimator changed.
  • SQL Server edition was updated from Standard to Enterprise.
  • SQL Server version (2016) was not changed.
  • The storage (SSD) was not changed.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I uploaded query plans for a simple query without hint and with hint.

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we updated the server, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Here are the server changes:

  • The compatibility level was updated from 2008 to 2016, thus the cardinality estimator changed.
  • SQL Server edition was updated from Standard to Enterprise.
  • SQL Server version (2016) was not changed.
  • The storage (SSD) was not changed.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I was not able to reproduce the same bad query plans from my previous production issues (the bad query plans happen randomly), but I was able to generate similar query plans using a new simple query. I uploaded plans for the simple query without hint and with hint.

OPTION (RECOMPILE) could solve the issue. But it does not ensure that the new query plan will be better or that SQL Server will not switch to another query plan in a few days. I am not looking for a way to improve one particular query or to improve one particular query plan. I want to globally prevent Clustered Index Scan on my table.

I have many queries that query many different columns and I cannot include all columns in all indexes.

One global option that would probably solve my issues is to use the legacy cardinality estimator, but I hope to find something better.

added 188 characters in body
Source Link
cao
  • 143
  • 1
  • 5

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we updated the server, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Here are the server changes:

  • The compatibility level was updated from 2008 to 2016, thus the cardinality estimator changed.
  • SQL Server edition was updated from Standard to Enterprise.
  • SQL Server version (2016) was not changed.
  • The storage (SSD) was not changed.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I uploaded query plans for a simple query without hint and with hint.

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we updated the server, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Here are the server changes:

  • The compatibility level was updated from 2008 to 2016, thus the cardinality estimator changed.
  • SQL Server edition was updated from Standard to Enterprise.
  • SQL Server version (2016) was not changed.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I uploaded query plans for a simple query without hint and with hint.

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we updated the server, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Here are the server changes:

  • The compatibility level was updated from 2008 to 2016, thus the cardinality estimator changed.
  • SQL Server edition was updated from Standard to Enterprise.
  • SQL Server version (2016) was not changed.
  • The storage (SSD) was not changed.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I uploaded query plans for a simple query without hint and with hint.

added 188 characters in body
Source Link
cao
  • 143
  • 1
  • 5

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we migrated to SQL Server 2016 and activatedupdated the new cardinality estimatorserver, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Here are the server changes:

  • The compatibility level was updated from 2008 to 2016, thus the cardinality estimator changed.
  • SQL Server edition was updated from Standard to Enterprise.
  • SQL Server version (2016) was not changed.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I uploaded query plans for a simple query without hint and with hint.

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we migrated to SQL Server 2016 and activated the new cardinality estimator, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I uploaded query plans for a simple query without hint and with hint.

My database contains a specific table that is quite large (250+M rows, 100+GB data space).

Generating a clustered index scan on this table is always a bad idea.

This table has multiple indexes and we never run a query on this table without specifying predicates on indexed columns.

Since we updated the server, we have experienced random query plan degradations. Queries that would run in a few seconds randomly start to timeout after multiple dozens of minutes.

Here are the server changes:

  • The compatibility level was updated from 2008 to 2016, thus the cardinality estimator changed.
  • SQL Server edition was updated from Standard to Enterprise.
  • SQL Server version (2016) was not changed.

Of course, I can easily solve this issue for one specific query by adding hints, but I have too many queries in my applications to broadly apply this solution.

Is there a way to globally prevent SQL Server from generating Clustered Index Scan on this table?

I uploaded query plans for a simple query without hint and with hint.

Post Closed as "Needs details or clarity" by mustaccio, LowlyDBA - John M, John K. N., Colin 't Hart, Marcello Miorelli
edited tags
Link
John K. N.
  • 18.3k
  • 14
  • 54
  • 115
Loading
added 139 characters in body
Source Link
cao
  • 143
  • 1
  • 5
Loading
edited body
Source Link
cao
  • 143
  • 1
  • 5
Loading
Source Link
cao
  • 143
  • 1
  • 5
Loading