Re: Explain

From: Sam Barnett-Cormack <s(dot)barnett-cormack(at)lancaster(dot)ac(dot)uk>
To: JEANARTHUR(at)EUROVOX(dot)FR
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Explain
Date: 2003-07-07 14:08:40
Message-ID: Pine.LNX.4.50.0307071506480.353-100000@short.lancs.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)EUROVOX(dot)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(at)postgresql(dot)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

In response to

  • Explain at 2003-07-07 13:58:57 from JEANARTHUR

Browse pgsql-admin by date

  From Date Subject
Next Message Vinay 2003-07-07 14:11:36 generic SQL implementations
Previous Message JEANARTHUR 2003-07-07 13:58:57 Explain