sql - effect of number of projections on query performance -
I am looking to improve the performance of a query that chooses multiple columns from one table. Thinking that limiting the number of columns would affect the execution of the query.
Maybe there is a misunderstanding of the question, but here goes anyway:
The absolute number does not make a big difference in the column you select. However, which can make significant differences based on the index of the selected column table.
If you are only selecting columns that are included in the index, then DB engines can use index only without bringing data to the table. If you do not use any single column which is not covered, however, it needs to bring the whole line (key lookup) and this will greatly reduce the performance. Occasionally this performance kills so much that the DB engine takes the option of full scan instead of bothering with the index; It depends on the number of rows to be selected.
So, if you can remove the columns and convert it to a cover query, yes, it can improve performance. Otherwise, probably not a quick example for SQL Server 2005+ - Suppose that this is your table:
ID int does not recognize the primary key class name, name varchar (50)
< / Pre>If we create this index:
Create Index IX_MyTable on Meritable (name)
Then this question will be faster:
Select from MyTable id where name = 'Aaron'
but this query will be slow (er):
Selection of position from My Location If we change an index to an index, i.e.
Create MyXableType (IX_MyTable) on MyTable (ie, name, status, where name = 'Aaron')
Name)
Then another query becomes faster because the DB engine never needs to read the row.
Comments
Post a Comment