From: PV <pstm.spain@gmail.com>
To: pgsql-performance@postgresql.org
Subject: static virtual columns as result?
Date: Tue, 03 Jul 2012 11:29:09 +0200
Message-ID: <4FF2BB65.7080903@gmail.com> (raw)
Hello,
I "have" this two tables:
Table Cat:
id|A|B
--+-+-
1|3|5
2|5|8
3|6|9
Table Pr:
id|Catid|
--+-
1|3
2|2
3|1
I need replace "Catid" column for corresponding values A and B (Table
Cat) in Table Pr.
Virtual table like this:
Table Pr:
id|Catid|A|B
--+-+-+
1|3|6|9
2|2|5|8
3|1|3|5
Something like this, but that works,...
SELECT * FROM pr WHERE pr.a /*> 1 AND*/*//*
<https://www.google.es/search?hl=es&sa=X&ei=ULbyT9uKGYSt0QWNy4CwCQ&ved=0CEUQvwUoAQ&q=...;
pr.b < 10;
With subqueries is too slow:
SELECT * FROM "Pr" AS p, (SELECT "id" AS cid FROM "Cat" WHERE "lft" > 1
AND "rgt" < 10) AS c WHERE p."Cat"=c."cid" AND (...)) ORDER BY "Catid"
ASC OFFSET 0 LIMIT 40
Any suggestion?
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-performance@postgresql.org
Cc: pstm.spain@gmail.com
Subject: Re: static virtual columns as result?
In-Reply-To: <4FF2BB65.7080903@gmail.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