Andrey
Andrey

Reputation: 1759

SQL General Optimization

recently was asked to help with query optimization

The table looks like this:

create table dbo.Table
( 
 id int identity primary key clustered ,
 column_1 varchar(64) not null  ,
 Date datetime not null ,
 Column_2 varchar (32) not null ,
 Column_3 int not null 
)

and select looks like

select * from Table where column_1 = @value1 and Date > @value2

I propose to show columns names instead of * in select , because it can help avoid loading unneeded data, also propose create nonclustered index on column_1. However, execution plan still shows the same amount of memory used by query.

What else should I check or add into the query?

Upvotes: 0

Views: 57

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269633

You can optimize the query by using indexes. The one you want would be on column_1 and date:

create index idx_table_column1_date on table(column_1, date);

Upvotes: 2

Related Questions