Re: Problems with non use of indexes

From: Tyler Durden <tylersticky(at)gmail(dot)com>
To: Tomas Vondra <tv(at)fuzzy(dot)cz>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problems with non use of indexes
Date: 2012-03-02 14:55:28
Message-ID: CAL0cWDTDSh5x0Dzfoya3uBhASAH-M7ODeaNuw3S2RU7ScuGiGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

http://explain.depesz.com/s/f92O

*EXPLAIN ANALYSE VERBOSE SELECT "activity_action"."id",
"activity_action"."actor_id", "activity_action"."verb",
"activity_action"."action_content_type_id",
"activity_action"."action_object_id",
"activity_action"."target_content_type_id",
"activity_action"."target_object_id", "activity_action"."public",
"activity_action"."created", "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email",
"auth_user"."password", "auth_user"."is_staff", "auth_user"."is_active",
"auth_user"."is_superuser", "auth_user"."last_login",
"auth_user"."date_joined" FROM "activity_action" INNER JOIN "auth_user" ON
("activity_action"."actor_id" = "auth_user"."id") WHERE
"activity_action"."actor_id" IN (SELECT U0."object_id" FROM
"activity_follow" U0 WHERE (U0."content_type_id" = 3 AND U0."user_id" = 1))
ORDER BY "activity_action"."created" DESC LIMIT 100;*

---

http://explain.depesz.com/s/o3w

EXPLAIN ANALYSE VERBOSE SELECT "activity_action"."id",
"activity_action"."actor_id", "activity_action"."verb",
"activity_action"."action_content_type_id",
"activity_action"."action_object_id",
"activity_action"."target_content_type_id",
"activity_action"."target_object_id", "activity_action"."public",
"activity_action"."created", "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email",
"auth_user"."password", "auth_user"."is_staff", "auth_user"."is_active",
"auth_user"."is_superuser", "auth_user"."last_login",
"auth_user"."date_joined" FROM "activity_action" INNER JOIN "auth_user" ON
("activity_action"."actor_id" = "auth_user"."id") WHERE
"activity_action"."actor_id" IN (SELECT U0."object_id" FROM
"activity_follow" U0 WHERE (U0."content_type_id" = 3)) ORDER BY
"activity_action"."created" DESC LIMIT 100;

---

http://explain.depesz.com/s/ccJ

EXPLAIN ANALYSE VERBOSE SELECT U0."object_id" FROM "activity_follow" U0
WHERE (U0."content_type_id" = 3 AND U0."user_id" = 1);

On Fri, Mar 2, 2012 at 2:23 PM, Tomas Vondra <tv(at)fuzzy(dot)cz> wrote:

> On 2 Březen 2012, 14:34, Tyler Durden wrote:
> > On Fri, Mar 2, 2012 at 12:55 PM, Tomas Vondra <tv(at)fuzzy(dot)cz> wrote:
> >
> >> On 2 Březen 2012, 13:45, Tyler Durden wrote:
> >> >>
> >> > Yes, but if I remove *U0."user_id" = 1 *will use the index:
> >>
> >> Which PostgreSQL version is that? Post EXPLAIN ANALYZE output for all
> >> three queries, not just EXPLAIN. And use explain.depesz.com if
> possible,
> >> it's much more readable.
> >>
> >> kind regards
> >> Tomas
> >>
> >
> > I'm using PostgreSQL 8.4.2 and you can find the EXPLAIN ANALYSE VERBOSE
> in
> > http://explain.depesz.com/s/hk2
>
> For all three queries, please.
>
> Tomas
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-03-02 15:11:14 Re: archive_cleanup_command recovery.conf Standby server error
Previous Message Tomas Vondra 2012-03-02 14:23:27 Re: Problems with non use of indexes