From: Josh Berkus <josh@agliodbs.com>
To: Peter T. Brown <peter@memeticsystems.com>
To: pgsql-sql@postgresql.org
Subject: Re: making queries more effecient
Date: Fri, 1 Nov 2002 14:09:01 -0800
Message-ID: <200211011409.01771.josh@agliodbs.com> (raw)
In-Reply-To: <1036189492.2013.16.camel@localhost.localdomain>
References: <1036189492.2013.16.camel@localhost.localdomain>
Peter,
For the rest of our sakes, in the future, please format your SQL before
posting it to request help.
> CREATE TEMP TABLE temp20561149207391 AS SELECT DISTINCT ON ("VisitorID")
> "VisitorID","Type" FROM "ProgramEvent" WHERE "ProgramID" = 10 ORDER BY
> "VisitorID","Created" DESC;INSERT INTO "VisitorPointer839" ("VisitorID")
> SELECT temp20561149207391."VisitorID" FROM temp20561149207391 WHERE
> temp20561149207391."Type" = 0
Can be re-written as:
INSERT INTO "VisitorPointer839" ("VisitorID")
SELECT "VisitorID" FROM (
SELECT DISTINCT ON ("VisitorID") "VisitorID","Type"
FROM "ProgramEvent" WHERE "ProgramID" = 10
ORDER BY "VisitorID","Created" DESC ) v_first
WHERE v_first."Type" = 0;
Please also keep in mind that the SELECT DISTINCT ON syntax is a
PostgreSQL-specific extension and is not portable.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
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, peter@memeticsystems.com
Subject: Re: making queries more effecient
In-Reply-To: <200211011409.01771.josh@agliodbs.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