Re: PHP Postgres query slower then PgAdmin

From: Emrah Mehmedov <emrah(dot)mehmedov(at)x3mlabs(dot)com>
To: Marcin Mańk <marcin(dot)mank(at)gmail(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-25 10:15:00
Message-ID: CAGRV00L75SnLUfWG5xLkKEazd6rMriJRzRu2=NzNhBehx8EBoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, Jun 24, 2013 at 12:04 PM, Marcin Mańk <marcin(dot)mank(at)gmail(dot)com> wrote:

> 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
>

Hi Marcin Mańk,

i run the query with analyze and explain and the time is pretty same as i
calculate in php code, solution is to improve query or FTS dictionaries.

Thank you.
--
Best regards, Emrah Mehmedov
Software Developer @ X3M Labs
http://www.extreme-labs.com

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Kevin Grittner 2013-06-25 13:20:29 Re: incorrect row estimates for primary key join
Previous Message Albe Laurenz 2013-06-25 07:33:57 Re: on disk and in memory