Re: why does this select hang postgres???

From: "Joe Conway" <joseph(dot)conway(at)home(dot)com>
To: "Jeremy Hansen" <jeremy(at)xxedgexx(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: why does this select hang postgres???
Date: 2001-08-10 18:38:54
Message-ID: 00b101c121cb$b5aac570$b4d210ac@jecw2k1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> select * from env_info,summary,plat_info;
>
> Is my statement broken? Is this not legal? Postgres just sits there....
>
> My goal is to select everything from multiple tables with one sql
> statement.
>
> Thank You!
> -jeremy
>

Well, you'll get everything and then some ;)

This statement is called a cartesian join. What that means you will get the
<# of rows in env_info> *times* <# of rows in summary> *times* <# of rows in
plat_info>. So if env_info has 1000 rows,summary has 5000 rows, and
plat_info has 200 rows, the query will try to return 1000 * 5000 * 200 =
1,000,000,000 rows! So while it may *seem* to just sit there, Postgres is
actually probably just working *really* hard.

HTH,

Joe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2001-08-10 18:42:59 Re: why does this select hang postgres???
Previous Message Jeremy Hansen 2001-08-10 18:38:32 Re: why does this select hang postgres???