From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Chris Smith <cdsmith(at)twu(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Interpreting query plan |
Date: | 2004-07-02 22:23:55 |
Message-ID: | 20040702152111.Y78595@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 2 Jul 2004, Chris Smith wrote:
> I've just noticed in the regular profiling information from our web
> application that a particular query on a fairly small database is taking about
> 15 seconds. The query is generated from software on the fly, hence its
> quirkiness -- if any of that is the problem, then I'll go ahead and fix it,
> but I can't imagine a few repeated WHERE conditions fooling the query
> optimizer.
>
> Anyway, I don't know how to interpret query plans. Can anyone give me a hand?
> To get the plan, I just plugged in various values -- The actual query is run
> with various different values, and even a few different lengths for the IN
> clause.
>
> miqweb=> explain select distinct t0.* from UserAccount t0, UserMapping t1
> where
> (t0.companyid = 123) and ((t0.companyid = 123) and (t0.userid = t1.userid)
> and
> (t1.groupid in (123, 234, 345, 456))) and (t0.companyid = 123);
Plain explain output is useful for finding what the plan is, but not as
useful for determining why a query takes a particular amount of time.
You might want to use "explain analyze" and send that result (which gives
the real time and real number of rows for different steps).
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2004-07-02 23:07:10 | Re: Row values |
Previous Message | Jan Wieck | 2004-07-02 21:39:08 | Re: incremental backups? |