Optimizing further

Поиск
Список
Период
Сортировка
От Ken Williams
Тема Optimizing further
Дата
Msg-id F2B69EAD-7F36-11D6-AFA5-0003936C1626@mathforum.org
обсуждение исходный текст
Ответы Re: Optimizing further
Re: Optimizing further
Re: Optimizing further
Список pgsql-general
Hi,

I'm wondering whether I need to do something to further optimize
a query.  My query looks like this:


   select price, date FROM foo
    WHERE date < '2000-07-01 00:29:00+10' and code='UCL'
    ORDER by date DESC, stock DESC
    LIMIT 100;

I've got over 7 million rows in the table, and a btree
index(date, code).  According to "explain", the query will be
executed as follows:

   Limit  (cost=0.00..393.45 rows=100 width=32)
     ->  Index Scan Backward using foo_date_code on trades
                                (cost=0.00..12309.13 rows=3128 width=32)

When I run the query, it takes a really long time (10 seconds)
the first time I execute it, and then returns instantly the
second time.

Is there something I need to do in order to get these running
faster, the *first* time?  I've run "VACUUM ANALYZE" on the
table after all the rows were inserted.

Thanks.

  -Ken


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

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: Close idle connections
Следующее
От: "Jim Morcombe"
Дата:
Сообщение: Help required with installing postgreSQL on SCO Openserver