pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Kovacs Baldvin <kb136@hszk.bme.hu>
Cc: pgsql-sql@postgresql.org
Subject: Re: Q on "Re: select is fast, update based on same where clause is slow "
Date: Fri, 21 Sep 2001 16:53:11 -0700
Message-ID: <web-123693@davinci.ethosmedia.com> (raw)
In-Reply-To: <Pine.GSO.4.33.0109212253200.29874-100000@ural2>

Bladvin,

> I understand why did Jeff's original solution not work. I understand
> why yours do.
> 
> But could you please explain me how the 74000^2 can be calculated
> for this original query?:

Sure.  In Jeff's original query, the updated instance of the table
(sessions2) and the referenced instance (s) are seperate, without any
JOIN or WHERE conditions to link them.  Under these conditions, SQL
engines do a CROSS JOIN, where every single one of the rows in the first
table is matched against every single one of the rows in the second
table.  This gives you a result set of the number of rows in sessions2 *
the number of rows in s.  74,000^2  Get it?

Example:

TableA:
1	A
2	B

Table B
7	H
8	G

SELECT * FROM TableA, TableB
1	A	7	H
1	A	8	G
2	B	7	H
2	B	8	G

-Josh

-Josh


______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



Message-ID: <web-123693@davinci.ethosmedia.com>
Permalink:  ../web-123693@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-123693@davinci.ethosmedia.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, kb136@hszk.bme.hu
  Subject: Re: Q on "Re: select is fast, update based on same where clause is slow "
  In-Reply-To: <web-123693@davinci.ethosmedia.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox