Unix Technical Forum

rows in explain

This is a discussion on rows in explain within the pgsql Admins forums, part of the PostgreSQL category; --> Hi all, I want to find out how PG gets rows when it explains a query. For example, when ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 05:03 AM
Lee Wu
 
Posts: n/a
Default rows in explain

Hi all,



I want to find out how PG gets rows when it explains a query.

For example, when I issue:



explain select count(*) from pg_class where relname='pg_class';

QUERY PLAN

--------------------------------------------------------------

Aggregate (cost=4.55..4.55 rows=1 width=0)

-> Seq Scan on pg_class (cost=0.00..4.55 rows=1 width=0)

Filter: (relname = 'pg_class'::name)

(3 rows)



Where and how PG get "rows=1"?



Thank you!


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 05:03 AM
Michael Fuhr
 
Posts: n/a
Default Re: rows in explain

On Fri, Jul 29, 2005 at 11:54:18AM -0600, Lee Wu wrote:
> explain select count(*) from pg_class where relname='pg_class';
> QUERY PLAN
> --------------------------------------------------------------
> Aggregate (cost=4.55..4.55 rows=1 width=0)
> -> Seq Scan on pg_class (cost=0.00..4.55 rows=1 width=0)
> Filter: (relname = 'pg_class'::name)
> (3 rows)
>
> Where and how PG get "rows=1"?


The planner uses statistics to estimate the number of rows that a
query will return. Here are a couple of links that provide more
information:

http://www.postgresql.org/docs/8.0/s...ner-stats.html
http://www.postgresql.org/docs/8.0/s...-pg-stats.html
http://www.postgresql.org/docs/8.0/s...l-analyze.html
http://developer.postgresql.org/docs...s-details.html

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:51 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com