trouble converting several serial queries into a parallel query

Поиск
Список
Период
Сортировка
От Jonathan Vanasco
Тема trouble converting several serial queries into a parallel query
Дата
Msg-id FE3E351A-04EF-4777-B248-A29425D290AC@2xlp.com
обсуждение исходный текст
Ответы Re: trouble converting several serial queries into a parallel query  (Chris Mair <chris@1006.org>)
Список pgsql-general
I have a very simple query that is giving me some issues due to the size of the database and the number of requests I
maketo it in order to compile the report I need: 

A dumbed down version of the table and query:

    CREATE TABLE a_to_b (
        id_a INT NOT NULL REFERENCES table_a(id),
        id_b INT NOT NULL REFERENCES table_b(id),
        PRIMARY KEY (id_a, id_b)
    );
    SELECT id_a, id_b FROM a_2_b WHERE id_a = 1 LIMIT 5;

The problem is that the table has a few million records and I need to query it 30+ times in a row.

I'd like to improve this with a parallel search using `IN()`

    SELECT id_a, id_b FROM a_2_b WHERE id_a = IN
(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26.27,28,29,30);

That technique has generally fixed a lot of bottlenecks for us.

However I can't wrap my head around structuring it so that I can apply a limit based on the column -- so that I only
get5 records per id_a. 

The table has columns that I would use for ordering in the future, but I'm fine with just getting random values right
now. 

Can anyone offer some suggestions?  Thanks in advance.

В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: could not fork new process for connection: Resource temporarily unavailable
Следующее
От: Filipe Pina
Дата:
Сообщение: Re: database-level lockdown