static virtual columns as result?

Поиск
Список
Период
Сортировка
От PV
Тема static virtual columns as result?
Дата
Msg-id 4FF2BB65.7080903@gmail.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: MemSQL the "world's fastest database"?
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: static virtual columns as result?