plan problem

Поиск
Список
Период
Сортировка
От Ken Geis
Тема plan problem
Дата
Msg-id 40731252.2030002@speakeasy.org
обсуждение исходный текст
Ответы Re: plan problem
Список pgsql-performance
I am trying to find an efficient way to draw a random sample from a
complex query.  I also want it to be easy to use within my application.

So I've defined a view that encapsulates the query.  The id in the
"driving" table is exposed, and I run a query like:

select * from stats_record_view
  where id in (select id from driver_stats
                order by random()
                limit 30000);

driver_stats.id is unique, the primary key.  The problem I'm having is
that neither the ORDER BY nor the LIMIT change the uniqueness of that
column, but the planner doesn't know that.  It does a HashAggregate to
make sure the results are unique.  It thinks that 200 rows will come out
of that operation, and then 200 rows is small enough that it thinks a
Nested Loop is the best way to proceed from there.

I can post more query plan, but I don't think it would be that very
helpful.  I'm considering just making a sample table and creating an
analogous view around that.  I'd like to be able to keep this as simple
as possible though.


Ken



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

Предыдущее
От: "Aaron Werman"
Дата:
Сообщение: Re: possible improvement between G4 and G5
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: possible improvement between G4 and G5