Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!eru!hagbard!sunic!news.funet.fi!uta!kielo!av From: av@kielo.uta.fi (Arto V. Viitanen) Newsgroups: comp.databases Subject: Re: no. of rows Message-ID: Date: 29 Oct 90 07:27:55 GMT References: Sender: news@uta.fi Reply-To: av@uta.fi (Arto Viitanen) Distribution: comp Organization: University of Tampere, Finland Lines: 27 Nntp-Posting-Host: uta.fi In-reply-to: ericco@ssl.berkeley.edu's message of 27 Oct 90 22:41:13 GMT >>>>> On 27 Oct 90 22:41:13 GMT, ericco@ssl.berkeley.edu (Eric C. Olson) said: Eric> I'm new to the SQL game, so bear with me. Is there a way of Eric> predicting the number of rows a query will return? For example: Eric> select column1 from table1 Eric> Can I find out how many rows will be returned? Do I have to make the Eric> query twice? I think that in every relational database is a thing called dictionary. It holds (at least) name of all users, relations, attributes, views etc. They can be used as any other relation, but only for querying, i.e. you can ask how some view is formed. There can also be statistics kept by Database Management System for query optimization, for example number of of rows in relation. In your example, you could select statistics for table1 and receive some prediction on number of rows. If you have more complex query, you should make some assumptions about distribution of values etc. i.e. the same job that query optimizer does. Since you know your data, your guesses are better than query optimizers, but still guesses. -- Arto V. Viitanen email: av@kielo.uta.fi University Of Tampere, av@ohdake.cs.uta.fi Finland