Re: PHP Postgres query slower then PgAdmin

From: Marcin Mańk <marcin(dot)mank(at)gmail(dot)com>
To: Emrah Mehmedov <emrah(dot)mehmedov(at)x3mlabs(dot)com>
Cc: Bob Jolliffe <bobjolliffe(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: PHP Postgres query slower then PgAdmin
Date: 2013-06-24 10:04:57
Message-ID: CAK61fk7K2FXyAMVLx6gM4P+mJ4hZ31N6DeByQZr9EX_2Yv6=Kw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, Jun 24, 2013 at 11:55 AM, Emrah Mehmedov
<emrah(dot)mehmedov(at)x3mlabs(dot)com> wrote:
> Marcin: This heppens everytime when i try to query different keyword in FTS
> for example:
>
> firsttime: query: "Hello & World" 15sec~
> secondtime: query: "Hello & World" 2-3sec
>
> then new query
>
> firsttime: query: "We & are & good" 10sec~
> secondtime: query: "We & are & good" 2-3sec
>
Now it looks like Postgres is fetching data from disk on first query
run, the second time it is from cache, so faster. Try:

EXPLAIN(ANALYZE, BUFFERS) SELECT title, url, ts_rank_cd(vector, query)
AS rank FROM links, to_tsquery('english', 'risk') query WHERE query @@
vector ORDER BY rank DESC LIMIT 10;

with varying queries, and post the results. This will show how many
blocks are are read from shared buffers, and how many are read from
the OS(either from OS disk cache, or the actual disk).

Regards
Marcin Mańk

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Ben 2013-06-24 22:18:11 incorrect row estimates for primary key join
Previous Message Emrah Mehmedov 2013-06-24 09:55:04 Re: PHP Postgres query slower then PgAdmin