pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Explain
4+ messages / 3 participants
[nested] [flat]

* Explain
@ 2003-07-07 13:58  JEANARTHUR@EUROVOX.FR
  0 siblings, 3 replies; 4+ messages in thread

From: JEANARTHUR@EUROVOX.FR @ 2003-07-07 13:58 UTC (permalink / raw)
  To: pgsql-admin

Hi,

when I do an explain on a certain query, I have this answer :


                                      QUERY PLAN
--------------------------------------------------------------------------------------
 Aggregate  (cost=100017927.48..100017927.48 rows=1 width=8)
   ->  Seq Scan on stats_daily_2003
(cost=100000000.00..100017927.47 rows=1 width=8)
         Filter: ((id_compte = 29075) AND (periode = '07-07-2003'::date))
(3 rows)


Well, I don"t really undestand the meaning of

cost=100000000.00..100017927.47

and

cost=100017927.48..100017927.48

I guess this result is relatively bad.

The same query on a similar table but with an index give :

                                                 QUERY PLAN
--------------------------------------------------------------------------------------------
----------------
 Aggregate  (cost=9.60..9.60 rows=1 width=8)
   ->  Index Scan using ap_stats_daily_2003_save on
stats_daily_2003_save  (cost=0.00..9.59 rows=2 width=8)
         Index Cond: ((periode = '07-07-2003'::date) AND (id_compte =
29075))
(3 rows)

Could you confirm me the second explain is "better" than the first one
?





Jean-Arthur Silve
EuroVox
4, Place Félix Eboué
75583 Paris Cedex 12
T : +33 1 44670505
F : +33 1 44670519







^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Explain
@ 2003-07-07 14:08  Sam Barnett-Cormack <s.barnett-cormack@lancaster.ac.uk>
  parent: JEANARTHUR@EUROVOX.FR
  2 siblings, 0 replies; 4+ messages in thread

From: Sam Barnett-Cormack @ 2003-07-07 14:08 UTC (permalink / raw)
  To: JEANARTHUR@EUROVOX.FR; +Cc: pgsql-admin

Yes - the lower the number, the faster the query *should* run. It's all
a bit heuristic, and the two values at each stage are lower and higher
cumulative estimates.

The main difference is the 'index scan' versus 'seq scan' - anything you
are going to do such scans on really should have an index, otherwise big
tables get very very slow.

On Mon, 7 Jul 2003 JEANARTHUR@EUROVOX.FR wrote:

> Hi,
>
> when I do an explain on a certain query, I have this answer :
>
>
>                                       QUERY PLAN
> --------------------------------------------------------------------------------------
>  Aggregate  (cost=100017927.48..100017927.48 rows=1 width=8)
>    ->  Seq Scan on stats_daily_2003
> (cost=100000000.00..100017927.47 rows=1 width=8)
>          Filter: ((id_compte = 29075) AND (periode = '07-07-2003'::date))
> (3 rows)
>
>
> Well, I don"t really undestand the meaning of
>
> cost=100000000.00..100017927.47
>
> and
>
> cost=100017927.48..100017927.48
>
> I guess this result is relatively bad.
>
> The same query on a similar table but with an index give :
>
>                                                  QUERY PLAN
> --------------------------------------------------------------------------------------------
> ----------------
>  Aggregate  (cost=9.60..9.60 rows=1 width=8)
>    ->  Index Scan using ap_stats_daily_2003_save on
> stats_daily_2003_save  (cost=0.00..9.59 rows=2 width=8)
>          Index Cond: ((periode = '07-07-2003'::date) AND (id_compte =
> 29075))
> (3 rows)
>
> Could you confirm me the second explain is "better" than the first one
> ?
>
>
>
>
>
> Jean-Arthur Silve
> EuroVox
> 4, Place Félix Eboué
> 75583 Paris Cedex 12
> T : +33 1 44670505
> F : +33 1 44670519
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>

-- 

Sam Barnett-Cormack
Software Developer                           |  Student of Physics & Maths
UK Mirror Service (http://www.mirror.ac.uk)  |  Lancaster University



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Explain
@ 2003-07-07 15:46  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: JEANARTHUR@EUROVOX.FR
  2 siblings, 0 replies; 4+ messages in thread

From: Stephan Szabo @ 2003-07-07 15:46 UTC (permalink / raw)
  To: JEANARTHUR@EUROVOX.FR; +Cc: pgsql-admin


On Mon, 7 Jul 2003 JEANARTHUR@EUROVOX.FR wrote:

> Hi,
>
> when I do an explain on a certain query, I have this answer :
>
>
>                                       QUERY PLAN
> --------------------------------------------------------------------------------------
>  Aggregate  (cost=100017927.48..100017927.48 rows=1 width=8)
>    ->  Seq Scan on stats_daily_2003
> (cost=100000000.00..100017927.47 rows=1 width=8)
>          Filter: ((id_compte = 29075) AND (periode = '07-07-2003'::date))
> (3 rows)
>
>
> Well, I don"t really undestand the meaning of
>
> cost=100000000.00..100017927.47
>
> and
>
> cost=100017927.48..100017927.48
>
> I guess this result is relatively bad.

This probably actually implies that you've done something like set
enable_seqscan=off at some point which makes the costs of seqscans very high
to discourage them. In any case, this plan is still expected to be much
more expensive than the below even when not taking that into account.  You
may also want to do explain analyze to get real world numbers rather than
just the estimates.

> The same query on a similar table but with an index give :
>                                                  QUERY PLAN
> --------------------------------------------------------------------------------------------
> ----------------
>  Aggregate  (cost=9.60..9.60 rows=1 width=8)
>    ->  Index Scan using ap_stats_daily_2003_save on
> stats_daily_2003_save  (cost=0.00..9.59 rows=2 width=8)
>          Index Cond: ((periode = '07-07-2003'::date) AND (id_compte =
> 29075))
> (3 rows)
>
> Could you confirm me the second explain is "better" than the first one
> ?






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Explain
@ 2003-07-07 15:55  JEANARTHUR@EUROVOX.FR
  parent: JEANARTHUR@EUROVOX.FR
  2 siblings, 0 replies; 4+ messages in thread

From: JEANARTHUR@EUROVOX.FR @ 2003-07-07 15:55 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; pgsql-admin

Thanks for your answer !

Yes, I set up enable_seqscan = off !

Thanks !

On 7 Jul 2003 at 8:46, Stephan Szabo wrote:

>
> On Mon, 7 Jul 2003 JEANARTHUR@EUROVOX.FR wrote:
>
> > Hi,
> >
> > when I do an explain on a certain query, I have this answer :
> >
> >
> >                                       QUERY PLAN
> > --------------------------------------------------------------------------------------
> >  Aggregate  (cost=100017927.48..100017927.48 rows=1 width=8)
> >    ->  Seq Scan on stats_daily_2003
> > (cost=100000000.00..100017927.47 rows=1 width=8)
> >          Filter: ((id_compte = 29075) AND (periode = '07-07-2003'::date))
> > (3 rows)
> >
> >
> > Well, I don"t really undestand the meaning of
> >
> > cost=100000000.00..100017927.47
> >
> > and
> >
> > cost=100017927.48..100017927.48
> >
> > I guess this result is relatively bad.
>
> This probably actually implies that you've done something like set
> enable_seqscan=off at some point which makes the costs of seqscans very high
> to discourage them. In any case, this plan is still expected to be much
> more expensive than the below even when not taking that into account.  You
> may also want to do explain analyze to get real world numbers rather than
> just the estimates.
>
> > The same query on a similar table but with an index give :
> >                                                  QUERY PLAN
> > --------------------------------------------------------------------------------------------
> > ----------------
> >  Aggregate  (cost=9.60..9.60 rows=1 width=8)
> >    ->  Index Scan using ap_stats_daily_2003_save on
> > stats_daily_2003_save  (cost=0.00..9.59 rows=2 width=8)
> >          Index Cond: ((periode = '07-07-2003'::date) AND (id_compte =
> > 29075))
> > (3 rows)
> >
> > Could you confirm me the second explain is "better" than the first one
> > ?
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster


Jean-Arthur Silve
EuroVox
4, Place Félix Eboué
75583 Paris Cedex 12
T : +33 1 44670505
F : +33 1 44670519







^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-07-07 15:55 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-07 13:58 Explain JEANARTHUR@EUROVOX.FR
2003-07-07 14:08 ` Sam Barnett-Cormack <s.barnett-cormack@lancaster.ac.uk>
2003-07-07 15:46 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2003-07-07 15:55 ` JEANARTHUR@EUROVOX.FR

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox