Re: PHP Postgres query slower then PgAdmin - Mailing list pgsql-performance

From Emrah Mehmedov
Subject Re: PHP Postgres query slower then PgAdmin
Date
Msg-id CAGRV00L75SnLUfWG5xLkKEazd6rMriJRzRu2=NzNhBehx8EBoA@mail.gmail.com
Whole thread Raw
In response to Re: PHP Postgres query slower then PgAdmin  (Marcin Mańk <marcin.mank@gmail.com>)
List pgsql-performance
On Mon, Jun 24, 2013 at 12:04 PM, Marcin Mańk <marcin.mank@gmail.com> wrote:
On Mon, Jun 24, 2013 at 11:55 AM, Emrah Mehmedov
<emrah.mehmedov@x3mlabs.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

pgsql-performance by date:

Previous
From: Albe Laurenz
Date:
Subject: Re: on disk and in memory
Next
From: Kevin Grittner
Date:
Subject: Re: incorrect row estimates for primary key join