Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!haven!vrdxhq!daitc!daitc.daitc.mil From: jkrueger@daitc.daitc.mil (Jonathan Krueger) Newsgroups: comp.databases Subject: Re: How do you... Message-ID: <472@daitc.daitc.mil> Date: 2 Apr 89 22:51:12 GMT References: <1707@anasaz.UUCP> <466@daitc.daitc.mil> <514@cullsj.UUCP> Sender: jkrueger@daitc.daitc.mil Reply-To: jkrueger@daitc.daitc.mil (Jonathan Krueger) Organization: Defense Applied Information Technology Center Lines: 18 In-reply-to: gupta@cullsj.UUCP (Yogesh Gupta) John Moore wrote: >> >A further restriction is that it must be in alphabetical order. I proved that I didn't read his article carefully: >> But you said you didn't care if they >> were sorted, you just wanted no extra cost for it. Yogesh Gupta spotted my mistake. Thanks to Yogesh, apologies to John. As noted by others, your query optimizer should decide to perform the select first, the sort on the selected rows second. If it's really good it might skip the sort if the storage structure maintains an order. Failing that, a single pass to verify that it's sorted should cost little. Failing even that, you can skip the explicit "order by" requirement and depend on side effects of the storage structure. -- Jon --