Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 High Availability (2005)
 Indexes

Author  Topic 

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-08-10 : 13:15:20
If you don't create indexes on your table at all, do all your rows remain unsorted and unindexed? Anything inserted, updated or deleted having no specific order?

I'm thinking if you do any SELECT at all, however simple, an execution plan is run in the background to determine the optimisation each time. Would this create indexes just this once to get a better result with less cost, and would the index be temporary or stay there? Would the nonclustered table & pointers remain, or disappear, or would the clustered sorting remain in place?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-10 : 13:26:55
Even with indexes, your data has no specific order when retrieved unless you specify an ORDER BY.

Indexes do not get created for you in the execution plan.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-08-10 : 13:28:42
SQL will never create an index for you behind the scenes. If you want indexes, you have to explicitly create them.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-08-10 : 13:40:36
Sure, not in an execution plan, no action taken, but when you run a SELECT query, I believe the server will choose between index options when there are big cost differences, and the results wouldn't be anything different, apart from timewise. Just wondering if this could leave an ordering on the rows if this indexing had been done to speed up the query?

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-10 : 14:53:01
Your second post is not clear.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-08-11 : 03:43:42
Not sure I understand.
The optimiser will pick the best indexes for the query. The indexes picked probably will affect the order of the rows.
That said, unless you specify an ORDER BY clause, you can say nothing about the expected order that the rows will be returned in. There's no such thing as a 'default row order' in SQL.

Bottom line, if you want the results in a particular order, specify an order by.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

nayeem4umd
Starting Member

1 Post

Posted - 2008-09-05 : 05:49:52
passing table to stored procedure in server-2005
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-09-05 : 14:18:58
quote:
Originally posted by nayeem4umd

passing table to stored procedure in server-2005



Please start a separate thread and state your question/problem clearly
Thanks

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -