Re: Query seem to slow if table have more than 200 million rows - Mailing list pgsql-performance

From Qingqing Zhou
Subject Re: Query seem to slow if table have more than 200 million rows
Date
Msg-id dh9ti0$ovs$1@news.hub.org
Whole thread Raw
In response to Query seem to slow if table have more than 200 million rows  ("Ahmad Fajar" <gendowo@konphalindo.or.id>)
Responses Re: Query seem to slow if table have more than 200 million rows
List pgsql-performance
""Ahmad Fajar"" <gendowo@konphalindo.or.id> wrote
>
> Select ids, keywords from dict where keywords='blabla' ('blabla' is a
> single
> word);
>
> The table have 200 million rows, I have index the keywords field. On the
> first time my query seem to slow to get the result, about 15-60 sec to get
> the result. But if I repeat the query I will get fast result. My question
> is
> why on the first time the query seem very slow.
>
> Table structure is quite simple:
>
> Ids bigint, keywords varchar(150), weight varchar(1), dpos int.
>

The first slowness is obviously caused by disk IOs. The second time is
faster because all data pages it requires are already in buffer pool. 200
million rows is not a problem for btree index, even if your client tool
appends some spaces to your keywords at your insertion time, the ideal btree
is 5 to 6 layers high at most. Can you show the iostats of index from your
statistics view?
http://www.postgresql.org/docs/8.0/static/monitoring-stats.html#MONITORING-STATS-VIEWS

Regards,
Qingqing



pgsql-performance by date:

Previous
From: Chris Browne
Date:
Subject: Re: int2 vs int4 in Postgres
Next
From: Tom Lane
Date:
Subject: Re: int2 vs int4 in Postgres