static virtual columns as result? - Mailing list pgsql-performance

From PV
Subject static virtual columns as result?
Date
Msg-id 4FF2BB65.7080903@gmail.com
Whole thread Raw
List pgsql-performance
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 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?

pgsql-performance by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: MemSQL the "world's fastest database"?
Next
From: "Kevin Grittner"
Date:
Subject: Re: static virtual columns as result?