Adding an Index to my table doesn't seem to be improving search performance - why is this?Does Foreign Key improve query performance?Why use the INCLUDE clause when creating an index?Improve INSERT-per-second performance of SQLite?How to improve performance of non-scalar aggregations on denormalized tablesIs it a good idea to always define a clustered index on a database table?Improve SQL CTE query performanceWhy does changing 0.1f to 0 slow down performance by 10x?Join table index performance improvements concernsStored Proc /Table Index ImprovementWhy can't see enum-type index in explain query?
What happens when redirecting with 3>&1 1>/dev/null?
Is it OK to look at the list of played moves during the game to determine the status of the 50 move rule?
Why is this integration method not valid?
If a character has cast the Fly spell on themselves, can they "hand off" to the Levitate spell without interruption?
why "American-born", not "America-born"?
Ribbon Cable Cross Talk - Is there a fix after the fact?
Can someone get a spouse off a deed that never lived together and was incarcerated?
Anatomically correct Guivre
How do I write real-world stories separate from my country of origin?
What defines a person who is circumcised "of the heart"?
Team member is vehemently against code formatting
Is ideal gas incompressible?
How to make Flex Markers appear in Logic Pro X?
Shell builtin `printf` line limit?
Nunc est bibendum: gerund or gerundive?
Why is unzipped file smaller than zipped file
Why the work done is positive when bringing 2 opposite charges together?
"Official wife" or "Formal wife"?
Why is Ni[(PPh₃)₂Cl₂] tetrahedral?
Is being an extrovert a necessary condition to be a manager?
How could the B-29 bomber back up under its own power?
Efficient Algorithms for Destroyed Document Reconstruction
Managing heat dissipation in a magic wand
How to test if argument is a single space?
Adding an Index to my table doesn't seem to be improving search performance - why is this?
Does Foreign Key improve query performance?Why use the INCLUDE clause when creating an index?Improve INSERT-per-second performance of SQLite?How to improve performance of non-scalar aggregations on denormalized tablesIs it a good idea to always define a clustered index on a database table?Improve SQL CTE query performanceWhy does changing 0.1f to 0 slow down performance by 10x?Join table index performance improvements concernsStored Proc /Table Index ImprovementWhy can't see enum-type index in explain query?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have the following on my Property
class:
[Index]
public Status PropertyStatus get; set;
Where Status
is an enum
containing one of five integer values, ranging from 0-4 inclusive.
When I run the following query:
SELECT TOP 100 * FROM [PROPERTY] WHERE PROPERTYSTATUS = 1
The query takes up to five minutes with only 30,000 rows.
I can't profile the query because the database is in Azure SQL. I do see the index:
What else can I do to troubleshoot / optimize this query?
UPDATE:
My schema is managed by EF Code-First, with the Property
class looking like this:
public class Property
[Key]
public int PropertyId get; set;
[Index(IsClustered = true)]
public Status PropertyStatus get; set;
[Index]
public bool InitiatedByUser get; set;
With the clustered index I do see improved performance.
sql sql-server performance indexing azure-sql-database
|
show 5 more comments
I have the following on my Property
class:
[Index]
public Status PropertyStatus get; set;
Where Status
is an enum
containing one of five integer values, ranging from 0-4 inclusive.
When I run the following query:
SELECT TOP 100 * FROM [PROPERTY] WHERE PROPERTYSTATUS = 1
The query takes up to five minutes with only 30,000 rows.
I can't profile the query because the database is in Azure SQL. I do see the index:
What else can I do to troubleshoot / optimize this query?
UPDATE:
My schema is managed by EF Code-First, with the Property
class looking like this:
public class Property
[Key]
public int PropertyId get; set;
[Index(IsClustered = true)]
public Status PropertyStatus get; set;
[Index]
public bool InitiatedByUser get; set;
With the clustered index I do see improved performance.
sql sql-server performance indexing azure-sql-database
Try optimizing with a Clustered index..CREATE CLUSTERED INDEX IX_status ON PROPERTY(status)
instead.
– Raymond Nijland
Mar 23 at 21:02
@RaymondNijland would you mind explaining why you're making this recommendation? I've read about this alternative but I'm not sure why this would improve SELECT statement performance.
– user666
Mar 23 at 21:06
2
Post yourCREATE TABLE
andCREATE INDEX
DDL as code instead of a screen image. The optimal index for this query would be either a clustered one onPROPERTYSTATUS
or a non-clustered index onPROPERTYSTATUS
with all other columns included. Be aware that the behavior ofTOP
withoutORDER BY
is not defined; you might get any 100 rows that satisfy the criterial.
– Dan Guzman
Mar 23 at 21:15
Please also post your reservation size in SQL Azure (Basic, S1, S2, etc). That limits your memory, CPU, and IO. If possible, post the query plan for your query since that will give much more insight into why it is taking time to return results. The short answer is that doing single column secondary indexes forces bookmark lookups into the heap/clustered index and these are generally more expensive than having a covering index to retrieve all columns (select top 100 * …). If you just retrieve the column of interest with current schema, it should be faster.
– Conor Cunningham MSFT
Mar 24 at 0:07
@ConorCunninghamMSFT How can I provide you with my query plan when running from SSMS?
– user666
Mar 24 at 2:43
|
show 5 more comments
I have the following on my Property
class:
[Index]
public Status PropertyStatus get; set;
Where Status
is an enum
containing one of five integer values, ranging from 0-4 inclusive.
When I run the following query:
SELECT TOP 100 * FROM [PROPERTY] WHERE PROPERTYSTATUS = 1
The query takes up to five minutes with only 30,000 rows.
I can't profile the query because the database is in Azure SQL. I do see the index:
What else can I do to troubleshoot / optimize this query?
UPDATE:
My schema is managed by EF Code-First, with the Property
class looking like this:
public class Property
[Key]
public int PropertyId get; set;
[Index(IsClustered = true)]
public Status PropertyStatus get; set;
[Index]
public bool InitiatedByUser get; set;
With the clustered index I do see improved performance.
sql sql-server performance indexing azure-sql-database
I have the following on my Property
class:
[Index]
public Status PropertyStatus get; set;
Where Status
is an enum
containing one of five integer values, ranging from 0-4 inclusive.
When I run the following query:
SELECT TOP 100 * FROM [PROPERTY] WHERE PROPERTYSTATUS = 1
The query takes up to five minutes with only 30,000 rows.
I can't profile the query because the database is in Azure SQL. I do see the index:
What else can I do to troubleshoot / optimize this query?
UPDATE:
My schema is managed by EF Code-First, with the Property
class looking like this:
public class Property
[Key]
public int PropertyId get; set;
[Index(IsClustered = true)]
public Status PropertyStatus get; set;
[Index]
public bool InitiatedByUser get; set;
With the clustered index I do see improved performance.
sql sql-server performance indexing azure-sql-database
sql sql-server performance indexing azure-sql-database
edited Mar 24 at 2:48
user666
asked Mar 23 at 20:55
user666user666
5901716
5901716
Try optimizing with a Clustered index..CREATE CLUSTERED INDEX IX_status ON PROPERTY(status)
instead.
– Raymond Nijland
Mar 23 at 21:02
@RaymondNijland would you mind explaining why you're making this recommendation? I've read about this alternative but I'm not sure why this would improve SELECT statement performance.
– user666
Mar 23 at 21:06
2
Post yourCREATE TABLE
andCREATE INDEX
DDL as code instead of a screen image. The optimal index for this query would be either a clustered one onPROPERTYSTATUS
or a non-clustered index onPROPERTYSTATUS
with all other columns included. Be aware that the behavior ofTOP
withoutORDER BY
is not defined; you might get any 100 rows that satisfy the criterial.
– Dan Guzman
Mar 23 at 21:15
Please also post your reservation size in SQL Azure (Basic, S1, S2, etc). That limits your memory, CPU, and IO. If possible, post the query plan for your query since that will give much more insight into why it is taking time to return results. The short answer is that doing single column secondary indexes forces bookmark lookups into the heap/clustered index and these are generally more expensive than having a covering index to retrieve all columns (select top 100 * …). If you just retrieve the column of interest with current schema, it should be faster.
– Conor Cunningham MSFT
Mar 24 at 0:07
@ConorCunninghamMSFT How can I provide you with my query plan when running from SSMS?
– user666
Mar 24 at 2:43
|
show 5 more comments
Try optimizing with a Clustered index..CREATE CLUSTERED INDEX IX_status ON PROPERTY(status)
instead.
– Raymond Nijland
Mar 23 at 21:02
@RaymondNijland would you mind explaining why you're making this recommendation? I've read about this alternative but I'm not sure why this would improve SELECT statement performance.
– user666
Mar 23 at 21:06
2
Post yourCREATE TABLE
andCREATE INDEX
DDL as code instead of a screen image. The optimal index for this query would be either a clustered one onPROPERTYSTATUS
or a non-clustered index onPROPERTYSTATUS
with all other columns included. Be aware that the behavior ofTOP
withoutORDER BY
is not defined; you might get any 100 rows that satisfy the criterial.
– Dan Guzman
Mar 23 at 21:15
Please also post your reservation size in SQL Azure (Basic, S1, S2, etc). That limits your memory, CPU, and IO. If possible, post the query plan for your query since that will give much more insight into why it is taking time to return results. The short answer is that doing single column secondary indexes forces bookmark lookups into the heap/clustered index and these are generally more expensive than having a covering index to retrieve all columns (select top 100 * …). If you just retrieve the column of interest with current schema, it should be faster.
– Conor Cunningham MSFT
Mar 24 at 0:07
@ConorCunninghamMSFT How can I provide you with my query plan when running from SSMS?
– user666
Mar 24 at 2:43
Try optimizing with a Clustered index..
CREATE CLUSTERED INDEX IX_status ON PROPERTY(status)
instead.– Raymond Nijland
Mar 23 at 21:02
Try optimizing with a Clustered index..
CREATE CLUSTERED INDEX IX_status ON PROPERTY(status)
instead.– Raymond Nijland
Mar 23 at 21:02
@RaymondNijland would you mind explaining why you're making this recommendation? I've read about this alternative but I'm not sure why this would improve SELECT statement performance.
– user666
Mar 23 at 21:06
@RaymondNijland would you mind explaining why you're making this recommendation? I've read about this alternative but I'm not sure why this would improve SELECT statement performance.
– user666
Mar 23 at 21:06
2
2
Post your
CREATE TABLE
and CREATE INDEX
DDL as code instead of a screen image. The optimal index for this query would be either a clustered one on PROPERTYSTATUS
or a non-clustered index on PROPERTYSTATUS
with all other columns included. Be aware that the behavior of TOP
without ORDER BY
is not defined; you might get any 100 rows that satisfy the criterial.– Dan Guzman
Mar 23 at 21:15
Post your
CREATE TABLE
and CREATE INDEX
DDL as code instead of a screen image. The optimal index for this query would be either a clustered one on PROPERTYSTATUS
or a non-clustered index on PROPERTYSTATUS
with all other columns included. Be aware that the behavior of TOP
without ORDER BY
is not defined; you might get any 100 rows that satisfy the criterial.– Dan Guzman
Mar 23 at 21:15
Please also post your reservation size in SQL Azure (Basic, S1, S2, etc). That limits your memory, CPU, and IO. If possible, post the query plan for your query since that will give much more insight into why it is taking time to return results. The short answer is that doing single column secondary indexes forces bookmark lookups into the heap/clustered index and these are generally more expensive than having a covering index to retrieve all columns (select top 100 * …). If you just retrieve the column of interest with current schema, it should be faster.
– Conor Cunningham MSFT
Mar 24 at 0:07
Please also post your reservation size in SQL Azure (Basic, S1, S2, etc). That limits your memory, CPU, and IO. If possible, post the query plan for your query since that will give much more insight into why it is taking time to return results. The short answer is that doing single column secondary indexes forces bookmark lookups into the heap/clustered index and these are generally more expensive than having a covering index to retrieve all columns (select top 100 * …). If you just retrieve the column of interest with current schema, it should be faster.
– Conor Cunningham MSFT
Mar 24 at 0:07
@ConorCunninghamMSFT How can I provide you with my query plan when running from SSMS?
– user666
Mar 24 at 2:43
@ConorCunninghamMSFT How can I provide you with my query plan when running from SSMS?
– user666
Mar 24 at 2:43
|
show 5 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318288%2fadding-an-index-to-my-table-doesnt-seem-to-be-improving-search-performance-wh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318288%2fadding-an-index-to-my-table-doesnt-seem-to-be-improving-search-performance-wh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try optimizing with a Clustered index..
CREATE CLUSTERED INDEX IX_status ON PROPERTY(status)
instead.– Raymond Nijland
Mar 23 at 21:02
@RaymondNijland would you mind explaining why you're making this recommendation? I've read about this alternative but I'm not sure why this would improve SELECT statement performance.
– user666
Mar 23 at 21:06
2
Post your
CREATE TABLE
andCREATE INDEX
DDL as code instead of a screen image. The optimal index for this query would be either a clustered one onPROPERTYSTATUS
or a non-clustered index onPROPERTYSTATUS
with all other columns included. Be aware that the behavior ofTOP
withoutORDER BY
is not defined; you might get any 100 rows that satisfy the criterial.– Dan Guzman
Mar 23 at 21:15
Please also post your reservation size in SQL Azure (Basic, S1, S2, etc). That limits your memory, CPU, and IO. If possible, post the query plan for your query since that will give much more insight into why it is taking time to return results. The short answer is that doing single column secondary indexes forces bookmark lookups into the heap/clustered index and these are generally more expensive than having a covering index to retrieve all columns (select top 100 * …). If you just retrieve the column of interest with current schema, it should be faster.
– Conor Cunningham MSFT
Mar 24 at 0:07
@ConorCunninghamMSFT How can I provide you with my query plan when running from SSMS?
– user666
Mar 24 at 2:43