Re: Nested query performance issue

Поиск
Список
Период
Сортировка
От Віталій Тимчишин
Тема Re: Nested query performance issue
Дата
Msg-id 331e40660904090225y3c2ddc37gcfb8cb97e301d2f8@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Nested query performance issue  (Glenn Maynard <glennfmaynard@gmail.com>)
Ответы Re: Nested query performance issue  (Glenn Maynard <glennfmaynard@gmail.com>)
Re: Nested query performance issue  (Greg Smith <gsmith@gregsmith.com>)
Re: Nested query performance issue  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-performance
OK, got to my postgres. Here you are:

create or replace function explode_array(in_array anyarray) returns setof anyelement as
$$
    select ($1)[s] from generate_series(1,array_upper($1, 1)) as s;
$$
language sql immutable;

SELECT s.* FROM score s
WHERE s.id IN (
  select
  -- Get the high scoring score ID for each game:
  explode_array(ARRAY(
      -- Get the high score for game g:
      SELECT s2.id FROM score s2 WHERE s2.game_id = g.id ORDER BY
s2.score DESC LIMIT 5
  ))
  FROM game g
);

It takes ~64ms for me

Best regards, Vitaliy Tymchyshyn

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

Предыдущее
От: "Rainer Mager"
Дата:
Сообщение: Re: difficulties with time based queries
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Nested query performance issue