New FAQ items

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: New FAQ items
Date: 1999-09-28 21:15:07
Message-ID: 199909282115.RAA04812@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here are two new FAQ items. They are on the web site, along with an
expanded TODO list.

---------------------------------------------------------------------------

4.22) How do I create a column that will default to the current time?

The tempation is to do:

create table test (x int, modtime timestamp default 'now');

but this makes the column default to the time of table creation, not the
time of row insertion.
Instead do:

CREATE TABLE test (x int, modtime timestamp default now() );

The calling of the function now() prevents the default value from being
computed at table creation time, and delays it until insertion time. We
believe this will not be a problem in post-6.5.* releases.

4.23) Why are my subqueries using IN so slow?

Currently, we join subqueries to outer queries by sequential scanning
the result of the subquery for each row of the outer query. A workaround
is to replace IN with EXISTS. For example, change:

SELECT *
FROM tab
WHERE col1 IN (SELECT col2 FROM TAB2)

to:

SELECT *
FROM tab
WHERE EXISTS (SELECT col2 FROM TAB2 WHERE col1 = col2)

We hope to fix this limitation in a future release.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Browse pgsql-general by date

  From Date Subject
Next Message ivan 1999-09-28 21:25:08 Re: [GENERAL] Solaris 7 x86 error
Previous Message Jim Cromie 1999-09-28 21:11:05 Referential Integrity functions for 2 different users