Re: URGENT! How many rows will be returned?

From: Kevin P. Fleming <kfleming_at_access-NOSPAM-laserpress.com>
Date: 1999/10/21
Message-ID: <NjNP3.3768$hX5.11706_at_news.rdc1.az.home.com>#1/1


The optimizer doesn't "work it out", it makes educated guesses. And it can only do this when there are histograms available for all the columns used in the WHERE clause, and those histograms were created with all the right parameters, etc.

In other words, you can't "know" how many rows a query will return without looking at the actual data involved, unless you have some other table(s) somewhere with counts of every relevant value in t1.column1 and t2.column2. This is what histograms are for, but they will only provide an approximation.

Sue Han <sue_han_at_my-deja.com> wrote in message news:7um7aj$c86$1_at_nnrp1.deja.com...
> Hi,
>
> How can I know how many rows will be returned from the query
>
> SELECT *
> FROM table1 t1, table2 t2
> where t1.column1 = t2.cloumn2;
>
> I know it can be done by
>
> SELECT count(*)
> FROM table1 t1, table2 t2
> where t1.column1 = t2.cloumn2;
>
> But I don't want to touch the actual data to get the information. Is
> there any statistics about that, and where is it stored? How can I get
> it by program?
>
> I am wondering how the optimizer works it out.
>
> Thanks in advance.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Thu Oct 21 1999 - 00:00:00 CEST

Original text of this message