Re: Slow Query - PostgreSQL 9.2

From: Vitaly Burovoy <vitaly(dot)burovoy(at)gmail(dot)com>
To: Saulo Merlo <smerlo50(at)outlook(dot)com>
Cc: Charles Clavadetscher <clavadetscher(at)swisspug(dot)org>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Slow Query - PostgreSQL 9.2
Date: 2016-01-11 23:01:08
Message-ID: CAKOSWNkX=D=kk9+jb6O=DSjy5ueq8+j8wh35rK4wNpZ4jkUY0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/11/16, Saulo Merlo <smerlo50(at)outlook(dot)com> wrote:
> Ok, thanks Vitaly.
> I need to create a TEXT or VARCHAR index.
> and another one with timestamptz
> How can I do?Thanks

How to create indexes of different types is written at [1].
But I thing you need something else. You have to create index on the
specified column(s). Type of data will be recognized by a column type.
Your primary goal is to avoid sequence scan of big tables. It is
important to read explain[2] and find _tables_ and _columns_ (or
_expressions_) where they appears in the "seq scan/filter" blocks to
decide whether it worth to create an index or not.
You can create index on expression[3] where column(s) of the table or
constants are involved, but keep in mind it is impossible to create an
index using columns of different tables or using non-constants (e.g.
"now()").

Note that your two last posts doesn't have information what columns you need.

[1] http://www.postgresql.org/docs/9.2/static/indexes-types.html
[2] http://www.postgresql.org/docs/9.2/static/using-explain.html
[3] http://www.postgresql.org/docs/9.2/static/indexes-expressional.html

P.S.: please, delete old (irrelevant) information which is not
necessary for answering.

>
> From: smerlo50(at)outlook(dot)com
> To: clavadetscher(at)swisspug(dot)org; vitaly(dot)burovoy(at)gmail(dot)com
> CC: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Slow Query - PostgreSQL 9.2
> Date: Mon, 11 Jan 2016 21:37:43 +0000
>
> Hey guys..
> How could I create a timestampandtz index?
> CREATE TABLE gorfs.inode_segments
> (
> <<overquoting>>
> )

--
Best regards,
Vitaly Burovoy

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2016-01-11 23:04:03 Re: WIP: CoC
Previous Message James Keener 2016-01-11 22:58:19 Re: WIP: CoC