Now I am looking for your help to create index on these.
Now this is my table structure
This the query I need index for maximum performance.
select PageId
from tblPages
where UrlChecksumCode = @UrlChecksumCode
and PageUrl = @PageUrl
Now I am very bad with indexes. I plan like that when the query is executing it will find first that UrlChecksumCode
rows then look pageurl columns. If you also explain me why to make such index I really appreciate that. Thank you.
In Object Explorer, expand the database that contains the table on which you want to create a nonclustered index. Expand the Tables folder. Expand the table on which you want to create a nonclustered index. Right-click the Indexes folder, point to New Index, and select Non-Clustered Index....
ALTER command to add and drop INDEXALTER TABLE tbl_name ADD INDEX index_name (column_list) − This adds an ordinary index in which any value may appear more than once. ALTER TABLE tbl_name ADD FULLTEXT index_name (column_list) − This creates a special FULLTEXT index that is used for text-searching purposes.
DDL - CREATE INDEX. Used to create an index on an existing table. The ALTER TABLE statement can also be used to create (or drop) an index on a table. The syntax for this command varies across systems.
A primary index is automatically created for the primary key and ensures that the primary key is unique. You can use the primary index to retrieve and access objects from the database. The unique index is a column, or an ordered collection of columns, for which each value identifies a unique row.
one way, since your pageURL is long(nvarchar(1000) and an index can only be 900 bytes if you don't use included columns, I have created this index with included columns
create index ix_IndexName on tblPages (UrlChecksumCode) INCLUDE(PageUrl)
or
create index ix_IndexName on tblPages (UrlChecksumCode) INCLUDE(PageUrl, PageID)
See also SQL Server covering indexes
why is URL nvarchar instead of varchar...can they be unicode? if not make it varchar and save 1/2 the size
Create Nonclustered Indexes
create nonclustered index indexname on tablename(columnname)
Drop Index
Drop Index index name on tablename
See all Indexes in a database
select * from sys.indexes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With