By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,852 Members | 2,259 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,852 IT Pros & Developers. It's quick & easy.

pre-sroted table (w/ index)

P: n/a
In TransacSQL, we used to have the tabled sorted by marking an index for
example by create_date.

This way we did not need to do an order by or at least it was faster.

Is there a way to force the table to be physicaly stroed sorted by a
certain index?

tia,
..V
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Thu, Oct 07, 2004 at 11:30:37AM -0500, Vic Cekvenich wrote:
In TransacSQL, we used to have the tabled sorted by marking an index for
example by create_date.

This way we did not need to do an order by or at least it was faster.
You'll always need to do an order by, as there's no guarantee of the
order of the results received. It may work today, but it may not tomorrow.
Is there a way to force the table to be physicaly stroed sorted by a
certain index?


Look in the manual for the SQL command 'CLUSTER'. It doesn't keep a
table ordered on disk as new inserts happen (it's very inefficient to
do so) but it'll order the existing data, which will often speed up
queries that return quite a lot of data from an index scan.

Cheers,
Steve

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.